Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 calling .sql file from query analyzer

Author  Topic 

jpotucek
Constraint Violating Yak Guru

273 Posts

Posted - 2009-10-19 : 10:09:12
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???

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2009-10-19 : 10:32:38
To execute in SSMS, you need to open the *.sql file.

For a batch , have a look at SQLCMD
Go to Top of Page
   

- Advertisement -