Scripts with CAST are treated like they should be CONVERT
heck4
Posts: 5 New member
in SQL Compare
As an example, I have this script:
<div>CREATE TABLE [dbo].[tblCastConvertTest]<br>(<br> [Id] INT NOT NULL IDENTITY(1,1)<br> ,[IsIncluded] BIT NOT NULL DEFAULT 1<br> ,[IsExcluded] AS CASE<br> WHEN [IsIncluded]=0 THEN CAST(1 AS BIT)<br> ELSE CAST(0 AS BIT)<br> END<br> ,CONSTRAINT [PK_tblCastConvertTest] PRIMARY KEY CLUSTERED ([Id])<br>)<br>GO<br></div>
After I execute it on the database and run a comparison, its showing a false positive difference:
Any ideas on why this is happening?
Tagged:
Answers
Redgate Software
Following @Mark R 's investigation, we've reproduced the issue and logged as it as SC-10390 in our internal bug tracking system. Thanks for reporting it! Please keep an eye on the release note.
Tianjiao Li | Redgate Software
Have you visited our Help Center?
Tianjiao Li | Redgate Software
Have you visited our Help Center?
The dev team has looked into this issue. To be fair, it's not an error in SQL Compare. The differences are real, and we're reporting them as such. As you said, it turns out that SQL Server is basically rewriting the CAST operation to a CONVERT operation under the covers.
You should be able to workaround it by using SQL Server's preferred CONVERT syntax instead of CAST.
Tianjiao Li | Redgate Software
Have you visited our Help Center?