Had a bit of a frustarting day today with SQL Server 2005! I was upgrading a database from 2000 to 2005 but at the same time stripping out some unwanted procedures, so I was proceeding one at a time …
I found that I was getting an error message "Invalid Syntax near ‘E’". I finally tracked this down to the following syntax not being liked by SQL 2005
… SQL Code …
IF @@ERROR = 0
RETURN (0)
–Error Handler
Error_Handler:
… Error Loggin SQL Code …
Yes! I know! You should use BEGIN TRY etc, etc in 2005, but these scripts I’m working on need to run in both 2000 and 2005.
This syntax was fine in 2000, but not in 2005. So … the fix? Well after 2 hours + scratching my head I found the following worked
… SQL Code …
IF
@@ERROR > 0 GOTO error_handler RETURN (0)error_handler
:Don’t ask me why ….
Dave Mc






Leave a comment