Hello:
how do I access an error code when
SELECT @.RESULTS EXEC('DBCC DBREINDEX('''+@.NAME+''') ')
fails because the database..table does not exists ?
@.RESULTS comes back with nothing but
I get
Server: Msg 2501, Level 16, State 1, Line 1
Could not find a table or object named 'Internet_Forms.test'. Check
sysobjects.
(Problem since @.NAME is populated from sysobjects.....)
Thanks
TThe batch is aborted after encountering this specific error, so you cannot
followup and catch the error. One thing you could do is check if the table
exists like so:
if object_id('mytable') is not null
begin
<o.k. do something>
end
else
begin
<table does not exist>
end
The following is a good tutorial on the subject:
http://www.sommarskog.se/error-handling-I.html
http://www.sommarskog.se/error-handling-II.html
"Support" <RemoveThis_Support@.mail.oci.state.ga.us> wrote in message
news:%23VCo9XZoFHA.1468@.TK2MSFTNGP12.phx.gbl...
> Hello:
> how do I access an error code when
> SELECT @.RESULTS EXEC('DBCC DBREINDEX('''+@.NAME+''') ')
> fails because the database..table does not exists ?
> @.RESULTS comes back with nothing but
> I get
> Server: Msg 2501, Level 16, State 1, Line 1
> Could not find a table or object named 'Internet_Forms.test'. Check
> sysobjects.
> (Problem since @.NAME is populated from sysobjects.....)
> Thanks
> T
>|||begin transaction
run querry
queryy @.@.error
commit when no error
rollback if erro
"Support" wrote:
> Hello:
> how do I access an error code when
> SELECT @.RESULTS EXEC('DBCC DBREINDEX('''+@.NAME+''') ')
> fails because the database..table does not exists ?
> @.RESULTS comes back with nothing but
> I get
> Server: Msg 2501, Level 16, State 1, Line 1
> Could not find a table or object named 'Internet_Forms.test'. Check
> sysobjects.
> (Problem since @.NAME is populated from sysobjects.....)
> Thanks
> T
>
>|||@.@.error returns noting becuase of JT's reason...
That's the problem
Thanks
"jose g. de jesus jr mcp, mcdba"
<josegdejesusjrmcpmcdba@.discussions.microsoft.com> wrote in message
news:B6A8654B-67F3-47F0-A93E-24D7E77F02F9@.microsoft.com...
> begin transaction
> run querry
> queryy @.@.error
> commit when no error
> rollback if erro
>
>
> "Support" wrote:
>
Wednesday, March 28, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment