Writing to text file from Stored Procedure

hi

Writing to text file from table/view is done using osql,bcp etc. How do we write output of stored procedure into text file

Thank you



Answer this question

Writing to text file from Stored Procedure

  • progchris

    D'oh. I had that in one of my iterations of testing. Thanks, Jens.

  • Stephen C. Steel

    SQLCMD, ISQL, or OSQL will work..

    With SQLCMD, you can do this to export a query (the query can be anything):

    sqlcmd -S.\yukon -E -Q "select * from sys.dm_exec_requests" -s, -W

    -S ServerName
    -E Trusted Connection
    -Q Run the following query and exit
    -s Seperator
    -W Remove trailing spaces



  • Laxmi.

    ..and then of course the -o switch for the ouput file.

    (..) -o C:\SomeOutputdata.txt

    HTH, jens Suessmeyer.


  • Writing to text file from Stored Procedure