How to execute a sql script from another script?

  • I need to execute mulitple SQL script from a main SQL script. How can this be accomplished ? I need to execuet the main script from Query Analyzer?

    Thanks

  • You can put the scripts in stored procedures and then issue multiple EXEC <stored proc name> commands from the Query Analyzer.

  • Another method is to can call xp_cmdshell from within your sql code to execute a OSQL command that runs each script.

    [/quote]

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

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

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