Board index » delphi » How can I use "try - except" in sql server query anlyzer ?

How can I use "try - except" in sql server query anlyzer ?


2004-06-08 06:41:54 PM
delphi174
Hi,
How can I catch exception on sql server query analyzer ?
(I mean like delphi try - except statement )
for example ;
I want to delete a record from my table but if mytable have got a relation
for this record , this code will be return relation error message.
But I want to catch this error and when error , do another thing .
like this (I use sample delphi code for describe my desire )
try
delete mytable where recordid = @recordid
except do sometihg..
end;
thanx a lot
 
 

Re:How can I use "try - except" in sql server query anlyzer ?

Kemal,
MS SQL doesn't have a 'try..except', but check out @@Error in Books Online.
Good luck,
krf
"Kemal Çoruhlu" <XXXX@XXXXX.COM>writes
Quote
Hi,

How can I catch exception on sql server query analyzer ?
(I mean like delphi try - except statement )

for example ;

I want to delete a record from my table but if mytable have got a relation
for this record , this code will be return relation error message.
But I want to catch this error and when error , do another thing .

like this (I use sample delphi code for describe my desire )

try
delete mytable where recordid = @recordid
except do sometihg..
end;

thanx a lot