Tuesday, March 27, 2012

About @@ERROR

Hi,
Can I use @.@.ERROR global variable to check the error returned by SQL DDL
commands.Are you saying that it doesn't work? Can you elaborate on your question? Some error will terminate
the batch. I suggest you check the two articles on error handling here: http://www.sommarskog.se/
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Shri.DBA" <ShriDBA@.discussions.microsoft.com> wrote in message
news:4CC53AC2-1747-4C8F-851B-2D057A2487E7@.microsoft.com...
> Hi,
> Can I use @.@.ERROR global variable to check the error returned by SQL DDL
> commands.
>|||IN addition to Tibor's comments, and you will find included in Erlands
articles.
Yes you can ( and should) use @.@.error to check DDL... You might also check
for existence of the object or column, etc..
The problem is that some errors cause the entire batch, or maybe just the
statement to abort, in which case, the rest of your code wouldn't run or
@.@.error might not be set appropriately..
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Shri.DBA" <ShriDBA@.discussions.microsoft.com> wrote in message
news:4CC53AC2-1747-4C8F-851B-2D057A2487E7@.microsoft.com...
> Hi,
> Can I use @.@.ERROR global variable to check the error returned by SQL DDL
> commands.
>

No comments:

Post a Comment