SQL Server Performance

Executing .Sql files in a folder

Discussion in 'Getting Started' started by bharathsivam, Mar 14, 2008.

  1. bharathsivam New Member

    Is there is a way to run the scripts from a file.
    For eg:
    Assume I have a folder named "Scripts"in location c: and there are files (say script1.sql, script2.sql,script3.sql etc) inside the folder. I want to run all the sql files in a single go.
    How can i acheive this in query analyser?
    Note: I had learnt to do this using osql utility. Please let me know if there is any other option?
  2. Adriaan New Member

    You can issue the exact same command line calling osql, using xp_cmdshell in QA. You may need to double up single quotes.
  3. satya Moderator

    You could get such a code example within updated books online for SQL Server 2000, in this case that is best one to refer further.
  4. FrankKalis Moderator

    Check out the
    :r <full path to the script to be included>
    method mentioned here: ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/3ec89119-7314-43ef-9e91-12e72bb63d62.htm
  5. bharathsivam New Member

    Im not able get what this is "ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/3ec89119-7314-43ef-9e91-12e72bb63d62.htm"
  6. FrankKalis Moderator

    [quote user="bharathsivam"]
    Im not able get what this is "ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/3ec89119-7314-43ef-9e91-12e72bb63d62.htm"
    This is the URL of the help topic in BOL. If you are using the English BOL version, you should be able to paste it into BOL. Otherwise just search for "sqlcmd Utility -> about sqlcmd utility" and then "Using the sqlcmd utility.
  7. bharathsivam New Member

    Apologies for the confusion Im using Sql server 2000.
    All the aswers pointing me again to use osql utility. Im looking for some other option.
  8. satya Moderator

    Open up SQL 2005 books online and type OSQL on the index or search.

Share This Page