Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1418
  • Last Modified:

How do you execute a .sql file in MS SQL Query Analyzer

Hello,

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 \.

Can anyone help?
0
jollykh
Asked:
jollykh
1 Solution
 
sathyagiriCommented:
@C:\Test.sql

or
run c:\test.sql
0
 
rbrookerCommented:
Hi,

open Query Analyzer, open the sql file and execute...

good luck.

:)
0
 
jollykhAuthor Commented:
I tried both methods and neither worked.

RUN C:\test.sql
gives me the error message "Syntax error at \"

When I attempted to open the file, it gave me all the SQL commands but all the commands started with the box-character.
0
 
rbrookerCommented:
Hi,

have you tried File -> Open and opened the sql file that way?
or you can open the sql file in notepad and copy and paste the contents.

:)
0
 
jrb1Commented:
It sounds like you have a corrupt file.  Maybe a tool lke TEXTPAD can read it successfully.

I do think you will have to open the file in Query Analzyer and run it.  The @script or run c:\script... are correct for Oracle, but I didn't think it worked in Query Analyzer.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now