Home Forums SQL Server 2005 T-SQL (SS2K5) insert printed messages from message tab into a table!!!! RE: insert printed messages from message tab into a table!!!!

  • Man, I had this exact same problem (with SQLSafe's xp_ss_list). I needed to capture the logical and filenames from the backups and darnit, it just wasn't capturing them any way, any how!

    As it turns out, I may actually have a solution! Ok, it ain't elegant by a long shot, and it's not totally complete yet, you will need to perform a few more substring tricks to extract the values. But hey, I LITERALLY just figured it out, and I'm overly excited to actually be able to contribute back to this site for a change. So here it is:

    create table #temp (result varchar(2000))

    go

    declare @cmdshell varchar(1500)

    declare @string varchar(100)

    set @string = '''\\SomeServer\SomeSQLSafeBackup.SAFE.BAK'''

    set @cmdshell = 'osql -S SomeServer -E -Q "master..xp_ss_list @filename = ' + @string + '"'

    insert into #temp

    EXEC master.dbo.xp_cmdshell @cmdshell

    select * from #temp

    How cool is that? Print it out in SQLCMD / osql, jam that into a temp table and presto... you have the results.

    I hope this helps out, maybe you have another situation where an extended proc or message to screen won't capture.

    You are welcome

    🙂

    G