Red Gate forums :: View topic - Primary key constraint dropped but not recreated.
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Compare 10
SQL Compare 10 forum

Primary key constraint dropped but not recreated.

Search in SQL Compare 10 forum
Post new topic   Reply to topic
Jump to:  
Author Message
Mattias



Joined: 30 Sep 2013
Posts: 4
Location: Sverige

PostPosted: Mon Sep 30, 2013 5:12 pm    Post subject: Primary key constraint dropped but not recreated. Reply with quote

SQL Compare 10.5.0.611

I am removing identity from a column so the table is dropped and recreated. But the recreated table does not get primary key constraint.
In a later stage this makes the whole installation fail because of a foreign key.

This is part of the created script with transactions removed for readability.

PRINT N'Dropping constraints from [dbo].[GroupOrVariableType]'
GO
ALTER TABLE [dbo].[GroupOrVariableType] DROP CONSTRAINT [PK_GroupOrVariableType]
GO
PRINT N'Rebuilding [dbo].[GroupOrVariableType]'
GO
CREATE TABLE [dbo].[tmp_rg_xx_GroupOrVariableType]
(
[id] [int] NOT NULL,
[descr] [varchar] (50) NULL
)
GO
INSERT INTO [dbo].[tmp_rg_xx_GroupOrVariableType]([id], [descr]) SELECT [id], [descr] FROM [dbo].[GroupOrVariableType]
GO
DROP TABLE [dbo].[GroupOrVariableType]
GO
EXEC sp_rename N'[dbo].[tmp_rg_xx_GroupOrVariableType]', N'GroupOrVariableType'
GO
PRINT N'Adding foreign keys to [dbo].[ConnectCall]'
GO
ALTER TABLE [dbo].[ConnectCall] ADD CONSTRAINT [FK_ConnectCall_GroupOrVariableType] FOREIGN KEY ([groupOrVariableTypeID]) REFERENCES [dbo].[GroupOrVariableType] ([id])
GO
Back to top
View user's profile Send private message AIM Address
Brian Donahue



Joined: 23 Aug 2004
Posts: 6580

PostPosted: Fri Oct 04, 2013 9:43 am    Post subject: Reply with quote

I'm unable to reproduce this issue, so I can't say what the problem is or how to fix it. As per usual, I would probably need the whole schema to try to reproduce the problem and get it fixed.

In the meantime, can you try downgrading to 10.4 and see if that fixes it?
http://downloads.red-gate.com/checkforupdates/SQLCompare/SQLCompare_10.4.8.87.exe
Back to top
View user's profile Send private message
Mattias



Joined: 30 Sep 2013
Posts: 4
Location: Sverige

PostPosted: Tue Oct 08, 2013 9:09 am    Post subject: Reply with quote

I downgraded but the problem is still there.
But the problem only occurs when I have Ignore Indexes checked. When I do, the script generator will not even create primary key constraints for new tables.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group