Outputting DBCC results

Sometimes it may be useful to reuse the result of the DBCC commands. If the DBCC command resturns a resultset, it can be outputted to a table.

Consider the following command

DBCC useroptions

It returns a single resultset. To copy the resultset to a table, you can use the following

Create table #dbcc_useroptions ([set option] varchar(100), [value] varchar(100))

insert into #dbcc_useroptions
exec('DBCC useroptions')

select * from #dbcc_useroptions

drop table #dbcc_useroptions

Note that it is possible with dynamically executing DBCC commands and only the DBCC commands that return a resultset can be used

Published Saturday, July 26, 2008 12:02 PM by Madhivanan


No Comments