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.
| Author |
Topic |
|
scmay
Starting Member
22 Posts |
Posted - 2007-09-10 : 22:15:57
|
Hi I just saw this at http://sequelserver.blogspot.com/ and am trying out the TRY...CATCH feature in SQL2005 but this example (quoted below) doesn't seem to work on my SQL Server 2005 Express Edition. Is the code example wrong or does it only work with SQL Server 2005 full version? quote: DECLARE @i int , @j intSELECT @i =100, @j =0 BEGIN TRY SELECT @i/@j END TRYBEGIN CATCH SELECT ERROR_NUMBER() as ErrorNo, ERROR_MESSAGE() as ErrMessageEND CATCH
I get error quote: Msg 170, Level 15, State 1, Line 4Line 4: Incorrect syntax near 'TRY'.Msg 156, Level 15, State 1, Line 6Incorrect syntax near the keyword 'END'.Msg 195, Level 15, State 10, Line 8'ERROR_NUMBER' is not a recognized function name.
|
|
|
Zoroaster
Aged Yak Warrior
702 Posts |
Posted - 2007-09-10 : 23:52:00
|
You have to use this in a stored procedure. Future guru in the making. |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2007-09-11 : 04:56:57
|
| works fine with me...error message is Divide by Zero--------------------keeping it simple... |
 |
|
|
|
|
|