execute a .sql file from query anyalyzer

  • I have a file called "test.sql" that is located on my C: Drive. I opened up MS SQL and opened Query Analyzer. How do I tell the Query Analyzer to execute the file "test.sql"? I tried entering "C:\test.sql" in the analyzer but I got the error message: Syntax error at \.

    I do not want to enable xp_cmdshell. I also have about 50 .sql files that I have to run in a particular order. is there a way to 'batch' these???

  • Hi,

    I think maybe you can create a schedule jobs to execute the T-SQL statements in different steps of a scheduled jobs.

    You can control the order of the steps by going into advanced tab.

    Regards,

    Golden

  • In query analyzer, file | open, choose the file.

    If you have multiple files to run, you can script this using isql/osql in a batch file. Enter each one as a parameter to one of those tools.

    osql -Q -i test.sql

    osql : http://msdn.microsoft.com/en-us/library/ms162806.aspx

  • sqlcmd is the (2005) replacement for osql

    The probability of survival is inversely proportional to the angle of arrival.

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

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