Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Crazy bug in SQL Server 2000
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 11/21/2012 :  19:13:02  Show Profile  Reply with Quote
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

-- Comment
if @X = 2

	print cast(@X as varchar(10)) + ' = 2'

print 'Done'

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.


Most Valuable Yak

15732 Posts

Posted - 11/22/2012 :  07:46:35  Show Profile  Visit robvolk's Homepage  Reply with Quote
Did you try enclosing that in BEGIN...END:
if @X = 2
	print cast(@X as varchar(10)) + ' = 2'
This is a standard good practice. If there's some kind of parser error that leads to a downstream processing error this may correct it (since similar tweaks you've made also correct it).

SQL 2000 is end-of-life, if you've patched your server to Service Pack 4 and still have the error, then you'll need to upgrade, or just rewrite your code. If the bug still exists in SQL Server 2008/2012 then you should file a bug report on Microsoft Connect.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000