List of SPs from batch

  • How to execute a list of stored procedures from a batch file with output going into several csv files?

  • I'm not sure I understand the problem. If you mean a CMD or BAT script why not just make multiple calls to osql, one for each output file?

  • Yes how to do the above in a batch file. ie Could you give me an example please?

    I've tried;

    osql -E -Sservername -dmaster

    exec sp_helpdb > 1.csv

    This didn't work.

     

     

  • YourCmd.cmd =

    osql -U username -P password -S SrvName -d dbName -n -i input1.sql -o 1.cmd

    osql -U username -P password -S SrvName -d dbName -n -i input2.sql -o 2.cmd

    osql -U username -P password -S SrvName -d dbName -n -i input3.sql -o 3.cmd

    input1.sql =

    set nocount on

    exec sp_helpdb

    input2.sql =

    set nocount on

    exec sp_who

    input2.sql =

    set nocount on

    SELECT * FROM SYSINDEXES 

    Should you have need to get return values back to your batch script refer to my post at:

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=23&messageid=136563#bm136607

     

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

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