Windows cmd file to create tables

  • Hello

    Im new to SQL Server and to all things to do with computing really.

    I have 221 DDL scripts to create the tables.

    I would like to call them all in one windows batch cmd file?

    Does anyone have experience of doing this and what is the best way of doign it?

    Best Regards

    Al.

  • Assuming the scripts are all in the same directory....you can use the DOS "FOR" command to iterate through each file and call osql to execute each of them. Something like this:

    for /F %S IN ("c:\scripts\*.sql") DO osql -S [Server] -d [Database] -E -i "%S"

    You'll have to tweak the statement for your particular circumstances...Run "FOR /?" from a command line to see the syntax of the FOR command and "osql /?" to see the syntax for osql (for osql you can also go here: http://technet.microsoft.com/en-us/library/aa214012(SQL.80).aspx)

    Kendal Van Dyke

    http://kendalvandyke.blogspot.com/

    Kendal Van Dyke
    http://kendalvandyke.blogspot.com/[/url]

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

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