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

David Emerson davide at dalyn.co.nz
Tue Jan 20 16:54:26 CST 2004


Thanks Robert.

It seems that if there was an error then both the error and 0 would be 
returned.  Is this correct? Or should there be an Else in there before 
Return (0)?

David

At 20/01/2004, you wrote:
>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
>
>_______________________________________________
>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