incorrect syntax near @@error | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

incorrect syntax near @@error

Hi, I am testing my existing Stored Procedure of SQL 7 on SQL2K.
During the execution of code i encounter the following error message "line 135 incorrect syntax near @@error" How to avoid this error. Do i need to rewrite the code in my SP? Thanks,
Are you able to post the procedure code (a least the bit just before and including the @@error?) Cheers

As soon as i execute the stored procedure i encounter the error. Exec SP_Name ‘param1′,’param2′,’param3′,’param4’ Server: Msg 170, Level 15, State 1, Procedure SP_Name, Line 30
Line 30: Incorrect syntax near ‘@@error’. MNK.
Hi, The code used in the procedure is raiserror(@@error,16,2)
Is the above use of system variable @@error the issue with SQL2K? In that case r any workarounds available! Thanks MNK.
yes I think it is… declare @err int
set @err = @@error
if @err > 13000 raiserror(@err,16,2) is the only workaround I can think of… Cheers
Twan, I have tried the workaround given and it is working. If this is the only workaround i need to change all the SP’s. As such this will be a major effort in terms of finding all the SP’s and replacing the code. Thanks for ur inputs MNK.
I think the above workaround also may not work. Because the error number in the raiserror must be user defined and should be between 13000 and 2147483647. But @@error returns a system error id which will be lower than 13000.
Oh, I didn’t see that ‘if @err > 13000’. Yes, that will work and is the only workaround.