December 15, 2003 at 4:13 am
Hi
Is it possible to trap a DBCC error as part of a SP and react accordingly.
E.G. I have an SP that uses a cursor to loop through my tables rebuilding indexes using DBCC DBREINDEX. If one of these fails due to space constraints, then I would prefer to move onto the next table. Currently, the SP fails.
something like
CURSOR
dbcc dbreindex(...)
if "no error" or "ERROR = lack of space"
fetch next
else
quit
I tried @@ERROR, but I don't think that applies to DBCC. I could try to work out if there's space before I attempt rebuild.
Any help would be appreciated.
Thanks
Andy
December 15, 2003 at 5:47 am
December 15, 2003 at 10:17 am
Hi.
Not sure that this is what I was after (although there's some useful stuff here). What I was looking for was an equivalent to @@ERROR for dbcc commands
In TSQL, you could do
insert into table values .....
if @@ERROR = 'You ran out of space' then continue
else quit
There doesn't seem to be a dbcc equivalent e.g.
dbcc dbreindex ...
if @@ERROR = 'You ran out of space' then continue
else quit
doesn't trap the error.
Andy
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply