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

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 try catch in T-sql 2005

Author  Topic 

rajkumarrai_bis
Yak Posting Veteran

78 Posts

Posted - 2007-01-23 : 23:12:53
I m trying following code in sql server 2005
but it is giving error

BEGIN TRY
-- Generate divide-by-zero error.
SELECT 1/0;
END TRY
BEGIN CATCH
-- Execute the error retrieval routine.
print 'Error'
END CATCH;

Errors are
Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'TRY'.
Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'END'.

Thanks in advance
i need this urgently

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-01-23 : 23:17:53
are you sure you are running this in a SQL Server 2005 server ?
The query runs fine in my 2005 server but in 2000, it gives the same error message.


KH

Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-01-24 : 12:03:58
i think he's connecting to sql server 2000 through management studio and mistakes one for 2k5.



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

rajkumarrai_bis
Yak Posting Veteran

78 Posts

Posted - 2007-01-24 : 18:13:44
Yeah you are right
i got to know that through @@version
thanks guys
Go to Top of Page
   

- Advertisement -