Solved

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

Posted on 2006-07-18
5
1,364 Views
Last Modified: 2008-01-09
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
Comment
Question by:jollykh
5 Comments
 
LVL 14

Expert Comment

by:sathyagiri
ID: 17134856
@C:\Test.sql

or
run c:\test.sql
0
 
LVL 18

Expert Comment

by:rbrooker
ID: 17134857
Hi,

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

good luck.

:)
0
 

Author Comment

by:jollykh
ID: 17134908
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
 
LVL 18

Accepted Solution

by:
rbrooker earned 250 total points
ID: 17135110
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
 
LVL 25

Expert Comment

by:jrb1
ID: 17135120
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now