I have a table called 'Testtable'
It has two columns
age int , notnull
name varhar(10), notnull
I wrote a stored procedure as follows to trap the error.
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
ALTER procedure sperror
@.a int,
@.n varchar(10),
@.err int,
@.ro int
As
insert into testtable(name,age) values (@.n,@.a)
select @.err = @.@.error, @.ro = @.@.rowcount
print @.ro
if @.err <> 0
print 'Error occorrred in stored procedure ' + str(@.err)
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
I was unable to get the message that I bold, when I execute it from query analyzer.
Regards,
Bhuwan
Regards,
Bhuwan
http://www.sommarskog.se/error-handling-II.html
"Bhuwan Bhaskar" <kxxx@.gmail.com> wrote in message news:OiwnD4fnIHA.1768@.TK2MSFTNGP05.phx.gbl...
I have a table called 'Testtable'
It has two columns
age int , notnull
name varhar(10), notnull
I wrote a stored procedure as follows to trap the error.
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
ALTER procedure sperror
@.a int,
@.n varchar(10),
@.err int,
@.ro int
As
insert into testtable(name,age) values (@.n,@.a)
select @.err = @.@.error, @.ro = @.@.rowcount
print @.ro
if @.err <> 0
print 'Error occorrred in stored procedure ' + str(@.err)
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
I was unable to get the message that I bold, when I execute it from query analyzer.
Regards,
Bhuwan
Regards,
Bhuwan
Showing posts with label testtableit. Show all posts
Showing posts with label testtableit. Show all posts
Wednesday, February 15, 2012
Error handling in Stored procedure
Subscribe to:
Posts (Atom)