insert dbcc statement result set into a table

  • I create a temp table in order to get the result of dbcc tracestatus() in that table. Then I want to select its name field. This is my code, which gives an error

    Incorrect syntax near the keyword 'dbcc'.

    create table #tb1 ([name] int, [status] int, [global] int, [session] int)
    insert into #tb1 exec(dbcc tracestatus())
    select [name] from #tb1

    But I can't correct the syntax error that I get. Can someone point out?

    * If it is possible to directly select the name field from dbcc tracestatus() then please show how.
    Thanks for your time.

  • here quotes should be added
    create table #tb1 ([name] int, [status] int, [global] int, [session] int)
    insert into #tb1 exec('dbcc tracestatus()')
    select [name] from #tb1

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply