Home All Groups Group Topic Archive Search About

ARITHABORT + IF Statement + Label Causing SqlException

Author
12 Dec 2006 1:01 AM
craig.wagner
I had a heck of a time coming up with a subject for this one.

I don't know if this is an ADO.NET or SQL Server issue, it's a pretty
gray area as far as I'm concerned.

I have a stored procedure as follows. This is a stripped down example
to illustrate the problem, not my real sproc.

CREATE PROCEDURE [dbo].[Test]
AS BEGIN
    SET ARITHABORT ON

    IF 1 = 1
        RETURN 0

  Handler:
END

I can create this sproc in SQL Server 2000 or 2005 without a problem. I
can execute the sproc from Query Analyzer/Managment Studio without a
problem.

When I call the SQL2000 version of the sproc from .NET, it executes
fine.

When I call the SQL2005 version of the sproc from .NET, I get an error
"Incorrect syntax near 'H'."

The 'H' being referenced is the first letter of the label "Handler." If
I change the label to "Fred" the error message states "Incorrect syntax
near 'F'."

I can fix this problem in one of two ways:

a) Block the statement after the IF with a BEGIN...END.
b) Remove the SET ARITHABORT ON

Has anyone else ever seen such a thing?

AddThis Social Bookmark Button