Comments
6 comments
-
Hello,
Thanks for supplying all of the output from SQL Compare... would it be possible to script a scenario that caused this problem to happen? I can see where the problem occurs in your deployment but I can't figure out how to reproduce it so I can submit a proper bug report. -
Brian Donahue wrote:Hello,
Thanks for supplying all of the output from SQL Compare... would it be possible to script a scenario that caused this problem to happen? I can see where the problem occurs in your deployment but I can't figure out how to reproduce it so I can submit a proper bug report.
I'll see what I can do. It may take some time for me to set this up. -
Here is a simple scenario for you to reproduce this error. Hope this helps.
-- Create identical TestA and TestB databases create database TestA ; go use TestA ; go create default [dbo].[empty_number] AS 0 ; go create table dbo.Table1 ( column1 char(10) not null, column2 int not null ) ; execute sp_bindefault N'dbo.empty_number', N'dbo.Table1.column2' ; go create database TestB ; go use TestB ; go create default [dbo].[empty_number] AS 0 ; go create table dbo.Table1 ( column1 char(10) not null, column2 int not null ) ; execute sp_bindefault N'dbo.empty_number', N'dbo.Table1.column2' ; go -- Now drop the "column2" in Table1 in the TestA database. use TestA ; go execute sp_unbindefault N'dbo.Table1.column2' ; go alter table dbo.Table1 drop column column2 ; go -- Now use SQL Compare 10 to generate a script to make TestB match TestA. Be sure to -- check the "Add object existence checks" option before generating the script. -- Run the generated script on the TestB database and see the error.
-
Yes, it looks like SQL Compare is putting extra parenthesis in the object existence check that is causing it to not find the object. I have logged a bug SC-6379. It's scripting this:
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'column2' AND object_id = OBJECT_ID(N'[dbo].[Table1]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[[dbo]].[empty_number]]]', 'D')) EXEC sp_unbindefault N'[dbo].[Table1].[column2]'
when it should be this...IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'column2' AND object_id = OBJECT_ID(N'[dbo].[Table1]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[dbo].[empty_number]', 'D')) EXEC sp_unbindefault N'[dbo].[Table1].[column2]'
-
Brian Donahue wrote:I have logged a bug SC-6379.
-
Hi Brian,
Any update on when the fix for this bug will be released?
Thanks,
John
Add comment
Please sign in to leave a comment.
In our case, we are dropping the "curr_count" column from the "max4sale" table. This column has the "empty_number" object bound to it for default values. Here is the relevant SQL Compare generated code...
The bug is in the IF EXISTS check for the "empty_number" binding. In this case:
is incorrect and should be generated as:
This bug causes the IF EXISTS to fail and the default remains bound to the column. So when the script tries to drop the column, if fails with the following error:
Please submit this bug to the developers for a fix. I hope it can be corrected soon as I have to manually correct my generated scripts right now. Thanks very much.