I noticed that when I script-out the dropping and re-creating of a foreign key constraint it would only work once – because the name-portion would be missing …

ALTER TABLE [dbo].[SomeTable] DROP CONSTRAINT [FK__SomeTable_SYS__FRSIn__1BFD2C07]
GO
ALTER TABLE [dbo].[SomeTable] WITH CHECK ADD FOREIGN KEY([SomeColumnName])
REFERENCES [dbo].[SomeOtherTable] ([SomeColumnName])
GO

The soution was to cut and paste the name portion from the DROP statement into the ADD statement …

ALTER TABLE [dbo].[SomeTable] WITH CHECK ADD CONSTRAINT [FK__SomeTable_SYS__FRSIn__1BFD2C07] FOREIGN KEY([SomeColumnName])
REFERENCES [dbo].[SomeOtherTable] ([SomeColumnName])
GO
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s