Question : How do I execute an sql script via the command prompt?

Hi All,

I am trying to execute an sql script (which consists of a simple select query) via the command prompt using -

osql -E -i c:\query1.sql

When attempting this, I get an error -

1> 2> Msg 102, Level 15, State 1, Server PADSVR038, Line 1
Incorrect syntax near '''.

Any ideas?

Answer : How do I execute an sql script via the command prompt?

Since you use SQL Server 2005, Would recommend using SQLCMD instead of the deprecated osql..

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

>> Incorrect syntax near '''.

Seems like an syntax error in your query1.sql file..
Posting the contents would help us to fix it out..
Random Solutions  
 
programming4us programming4us