spooling a local variable

  • How to spool the output from T-SQL to a text file. I have the output in the form of a local variable. So xp_cmdshell 'osql..' will not work.

  • Preview

    Try using echo:

    
    
    declare @lvar varchar(500)
    select @lvar='"@ECHO '+ @yourlocalvariable +' >> C:\YourOutputFile.txt"'
    exec master..xp_cmdshell @lvar

    Another way is to store your local var in a temp table and then use isql with -Q -o options

  • You can use osql, just PRINT or SELECT your variable whenever you need output.

    Steve Jones

    steve@dkranch.net

  • The @echo technique worked fine.

    Thanks.

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

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