Question

if i try to run following code in sql server 2005 i get error

BEGIN TRY

        SELECT 1/0;
    END TRY
    BEGIN CATCH
        SELECT
            ERROR_NUMBER() AS ErrorNumber
            ,ERROR_SEVERITY() AS ErrorSeverity
            ,ERROR_STATE() AS ErrorState
            ,ERROR_PROCEDURE() AS ErrorProcedure
            ,ERROR_LINE() AS ErrorLine
            ,ERROR_MESSAGE() AS ErrorMessage;
    END CATCH;
    GO

Error:

Line 1: Incorrect syntax near 'TRY'.
Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'END'.
Msg 195, Level 15, State 10, Line 7
'ERROR_NUMBER' is not a recognized function name.

i was using sql server 2000 service manager but now i have installed sql server 2005 service manager but still get the error..one article related to it says

the reason for a such error is seems to be the target database is running on a MS SQL Server 2000 server. So be sure that your database server is SQL2005

what does it mean..?what changes i have to do???

Was it helpful?

Solution

You need to be using SQL Server 2005 or above to be able to use TRY...CATCH, installing SQL Server Management Studio will not help if you are still connecting to a SQL 2000 server.

OTHER TIPS

the reason for a such error is seems to be the target database is running on a MS SQL Server 2000 server. So be sure that your database server is SQL2005

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top