Wednesday, March 21, 2012

dbcc output capture

Hi
Is there a way to capture the dbcc output into a t-sql variable or in
table.
Thanks
Mangesh
Mangesh Deshpande wrote:
> Hi
> Is there a way to capture the dbcc output into a t-sql variable
> or in table.
>
> Thanks
> Mangesh
Many DBCC statements in SQL 2000 offer a WITH TABLERESULTS option that
return the information as a result set. You can insert into a temp table
using:
create table #dbcc_test (tran_item nvarchar(128), tran_val
nvarchar(128))
insert into #dbcc_test
Exec ('dbcc opentran (''pubs'') with tableresults')
Select * from #dbcc_test
Drop table #dbcc_test
David Gugick
Imceda Software
www.imceda.com
|||I'm not sure which command you're trying to capture results for, but please
note that the TABLERESULTS option is not supported for use with DBCC
commands unless Books Online specifically indicates its use in the syntax
diagram.
Thanks,
Ryan Stonecipher
Microsoft SQL Server Storage Engine, DBCC
This posting is provided "AS IS" with no warranties, and confers no rights.
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:%23sso5TsIFHA.1860@.TK2MSFTNGP15.phx.gbl...
> Mangesh Deshpande wrote:
> Many DBCC statements in SQL 2000 offer a WITH TABLERESULTS option that
> return the information as a result set. You can insert into a temp table
> using:
> create table #dbcc_test (tran_item nvarchar(128), tran_val nvarchar(128))
> insert into #dbcc_test
> Exec ('dbcc opentran (''pubs'') with tableresults')
> Select * from #dbcc_test
> Drop table #dbcc_test
>
> --
> David Gugick
> Imceda Software
> www.imceda.com
|||Thanks. The real coincedence. I wanted to write the script to use
dbcc indexdefrag using dbcc showcontig utility by capturing the output and
selectively running for some tables where scan density is low. But I found
the exact same script in MS SQL 2000 doc. Thanks again.
"Ryan Stonecipher [MSFT]" wrote:

> I'm not sure which command you're trying to capture results for, but please
> note that the TABLERESULTS option is not supported for use with DBCC
> commands unless Books Online specifically indicates its use in the syntax
> diagram.
> Thanks,
> --
> Ryan Stonecipher
> Microsoft SQL Server Storage Engine, DBCC
> This posting is provided "AS IS" with no warranties, and confers no rights.
> "David Gugick" <davidg-nospam@.imceda.com> wrote in message
> news:%23sso5TsIFHA.1860@.TK2MSFTNGP15.phx.gbl...
>
>

No comments:

Post a Comment