[dba-SQLServer]Error Handler (was Sproc not returning records)

Djabarov, Robert Robert.Djabarov at usaa.com
Tue Jan 20 16:15:01 CST 2004


Declare @error int, @cmd varchar(8000)
...
Set @error = @@error
If @error != 0 begin
   set @cmd = 'Unexpected error occurred: ' + cast(@error as
varchar(25))
   raiserror (@cmd, 15, 1)
   return @error
End
Return (0)

-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David
Emerson
Sent: Tuesday, January 20, 2004 4:06 PM
To: dba-SQLServer at databaseadvisors.com
Subject: [dba-SQLServer]Error Handler (was Sproc not returning records)


This was a handler I was given by someone else.  What is wrong with it
and 
how should it be fixed?

Regards

David Emerson
Dalyn Software Ltd
25 Cunliffe St, Churton Park
Wellington, New Zealand
Ph/Fax (877) 456-1205

At 20/01/2004, Robert Djabarov  wrote:
>The error handling specified will not work correctly if the actual 
>error occurs.
>
>/*
>If @@Error <> 0
>      Begin
>           Select 'Unexpected error occurred: ', @@Error
>           Return @@Error
>      End
>else
>     return 0
>*/

_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com



More information about the dba-SQLServer mailing list