sp_who

  • Is it possible to read the results of sp_who into a temp table or array of some sort?

  • Try something like

    create table spwhotbl

     (

      spid int,

      ecid int,

      status varchar(50),

      loginname varchar(100),

      hostname varchar(100),

      blk int,

      dbname varchar(100) null,

      cmd varchar(20)

    &nbsp

    go

    insert into spwhotbl exec sp_who

    The table definition may need minor modifications when it comes to length and nullability of fields 

     

  • Works perfectly! Thanks Jesper!

  • Although the following syntax will insert the results of the sp into a table, how can I append another value to the result set?

    INSERT INTO tblTest EXEC sp_who

    For example, if I had another column in tblTest that needed to be populated with lets say a custom value how can I amend the sql above to return the results of sp_who into tblTest as well as adding a custom value?

     

    Thanks

  • Select results into tblTest as above, then copy everything to another table (with an extra column) while populating the extra column. I don't think there is an easier way...

     

Viewing 5 posts - 1 through 4 (of 4 total)

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