osql

  • hi,

    i have a stored proc "test" currently in a db.

    I am writing a .bat file - that should execute that stored procedure.

    osql -E -q "EXEC test" -o "C:\out.txt"

    But i want to make some changes to the stored proc...... is it possible for me to include it within the batchfile.

    like: osql -E -q "create proc test (with lots of select, delete stmts following within the proc)" osql -e -q"exec test" -o"C:\out.txt"

    How to create and execute a stored proc using osql.

    Thnx.

     

     

  • If you want to run something too big for the command line, save it in a script file and use -i {inputfile} instead of -q {query}.

    As an alternative to -i and -o, you can use the < and > input and output redirection operators:

    osql -E < c:\path\input.sql > c:\path\results.txt

     

  • Hi,

    I have a test.sql - which contains about 4 stored procedure (create proc t1, t2,t3,t4) within it.

    I want to call and execute this through a batch file.

    so i have this .bat file:

    osql -E -e -ddbname -iC:\test.sql

    osql -E -e -ddbname -oC:\out.txt -n -q "EXEC dbname.dbo.t1"

    osql -E -e -ddbname >>C:\out.txt -n -q "EXEC dbname.dbo.t2"

    osql -E -e -ddbname >>C:\out.txt -n -q "EXEC dbname.dbo.t3"

    osql -E -e -ddbname >>C:\out.txt -n -q "EXEC dbname.dbo.t4"

    pause

    Is this how the .bat file is to be for all procedure to execute? How to get a prompt saying that the proc finished after each execution.

    Thnx

  • It's obvious you're too young to have been using computers in the pre-Windows era on Flintstone-style Teletypes.  Lucky you.

    You can use the ECHO command in a bat file to display any message you like.

    osql ...

    echo T1 finished

    osql ...

    echo T2 finished

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

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