Sql 2005: want to run script file from t-sql

  • Works for sql statements: ExecuteSql ('sql statement')

    BUT I want is this:

    ExecuteSQLScript(filename.sql)

    where filename.sql is a text file containing a t-sql script. Does this functionality exist in MS SQL?

    TIA,

    Barkingdog

  • I don't have the right name, but if you search for utility in books online, you will get that list and sample code.

    The QOTD section also has a section for utilities. I'm sure you could get a lot of ideas from there as well.

  • In SQLCMD mode you can use

    :r file.sql

    to include input from an external file. Read about it in Books Online, the external file is run after GO and not at the point where :r appears. You may also have multiple :r commands.

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

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