I had a weird issue in an SQL Server 2000 stored procedure. I distilled the critical part of the procedure down to:
declare @X int
set @X = 1
if @X = 2
print cast(@X as varchar(10)) + ' = 2'
The output is:
1 = 2
Naturally it is disconcerting to find that 1 is equal to 2 and if-statements don't work! There are a few things that I've noticed will fix it, but none of them are ideal:
i. Deleting the comment
ii. Changing the comment from using '--' to using /* ... */
iii. Deleting the blank row after the if-statement
iv. Upgrading to a newer version of SQL Server (or a different RDBMS altogether)
Fortunately option iv. above is only a couple of weeks away, but if anyone knows of a patch or something for this problem, please let me know.