Use osql utility to execute sql statements

  • I generated a script to recreate all the stored Procedures of a given database on a copy of my database on a second server. I saved this script as a file, named it "My_Script,sql" and put on on 'C' drive.

    Then on the command line I typed:

    osql -E -sServername -ddatabasename -Q " Execute C:\My_Script,sql"

    My stored procedures were not created in my database.

    What I am doing wrong?

    P.S. The script contains all the code for Create Procs.

    Faye

  • Is there any reason you aren't running them in Query Analyzer or SSMS? (You didn't indicate a version) Are you trying to automate the process or is this a one time run.

    "Execute" is not a valid OSQL command.

    Here's an exampl from BOL, section "Running the osql Utility":

    Connecting to a named instance using Windows Authentication and specifying input and output files:

    osql -E -S ComputerName\InstanceName -i MyScript.sql -o MyOutput.rpt

    Chris.

    Chris.

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

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