To get the results of the DBCC Commands in the SQL Table, Here is what you can do.

I will take the example of using DBCC SQLPERF(UMSSTATS)
First Execute the DBCC SQLPERF(UMSSTATS), and see the format of the result, in this case we have 2 columns, so we will create a table with 2 columns

drop table #umsstats

create table #umsstat
(
Statistic varchar(30),
value int
)
Now we will check to see if the direct insert statement works ?

insert into #umsstat
DBCC SQLPERF (UMSSTATS)

It will throw this error on Screen:

Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword ‘DBCC’.

we have to execute the DBCC commands using another method and it is :
EXEC(‘DBCC SQLPERF(UMSSTATS)’)

Now just try to execute this query and yes it works.

insert into #umsstat
EXEC(‘DBCC SQLPERF(UMSSTATS)’)

Now go back to your Querying the table like
select sum(value) from #umsstat where Statistic  = ‘  num users’ Or anything.
select * from #umsstat

Here are some more DBCC Commands you can work with.

DBCC SQLPERF(LOGSPACE)
DBCC SQLPERF(UMSSTATS)
DBCC SQLPERF(THREADS)
DBCC SQLPERF(IOSTATS)
DBCC SQLPERF(WAITSTATS)
DBCC SQLPERF(SPINLOCKSTATS)
DBCC SQLPERF(NETSTATS)

© 2010 D B A N A T I O N Suffusion WordPress theme by Sayontan Sinha
Better Tag Cloud