Red Gate forums :: View topic - The ALTER TABLE statement conflicted with the FOREIGN KEY
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Refactor 1
SQL Refactor 1 forum

The ALTER TABLE statement conflicted with the FOREIGN KEY

Search in SQL Refactor 1 forum
Post new topic   Reply to topic
Jump to:  
Author Message
ricci.s



Joined: 12 Apr 2010
Posts: 4

PostPosted: Tue Apr 13, 2010 1:44 pm    Post subject: The ALTER TABLE statement conflicted with the FOREIGN KEY Reply with quote

Hi everyone,

While using SQL Refactor to rename some columns, I came across the following error:

The ALTER TABLE statement conflicted with the FOREIGN KEY constraint

This error does not always crop up when the primary key of the table being renamed is an INT, so I was wondering why this error occurs and if there are any solutions round this?

Thanks,

Ricci
Back to top
View user's profile Send private message
ricci.s



Joined: 12 Apr 2010
Posts: 4

PostPosted: Wed Apr 14, 2010 2:07 pm    Post subject: Reply with quote

A quick update,

I noticed that before the insert statement there is no SET IDENTITY_INSERT ON

this isnt always the case as it appears sometimes, but not all the time.

Using the SET IDENTITY_INSERT ON before and SET IDENTITY_INSERT OFF after the insert resolves the problem.
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6577

PostPosted: Wed Apr 14, 2010 5:20 pm    Post subject: Reply with quote

Hello,

I'd appreciate it if you could try the latest cumulative patch to Refactor. The current release tries to rebuild tables when it doesn't need to -- this stands out in my mind as a reason for the Refactor script trying to insert data when smart rename should be strictly about the schema in most cases.

Here is a link to the information about the patch:
http://www.red-gate.com/MessageBoard/viewtopic.php?t=9960
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6577

PostPosted: Mon Apr 19, 2010 2:58 pm    Post subject: Reply with quote

Just following up -- did the cumulative patch (build 55) fix the problem?
Back to top
View user's profile Send private message
ricci.s



Joined: 12 Apr 2010
Posts: 4

PostPosted: Mon Apr 19, 2010 3:00 pm    Post subject: Reply with quote

I've not updated yet, but once I do I will post if the situation has been resolved.

Thanks.
Back to top
View user's profile Send private message
ricci.s



Joined: 12 Apr 2010
Posts: 4

PostPosted: Mon Apr 19, 2010 4:12 pm    Post subject: Reply with quote

Having tried the patch you suggested, when I renamed a primary key column, i get the following error message displayed:

An error occurred while generating the refactoring: Object reference not set to an instance of an object.. Please contact support@red-gate.com
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6577

PostPosted: Mon Apr 19, 2010 5:31 pm    Post subject: Reply with quote

Hi,

Can you pelase send the SQL Refactor log to support@red-gate.com and quote F0033501 in the subject line? You can find the log file in %userprofile%\local settings\application data\red gate\sql refactor\options
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6577

PostPosted: Fri Apr 23, 2010 9:51 am    Post subject: Reply with quote

Hi,

This looks like an unrelated problem caused by insufficient rights to decrypt encrypted objects.
Back to top
View user's profile Send private message
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