Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running sql file from command prompt

Status
Not open for further replies.

kindus

IS-IT--Management
Jul 25, 2001
77
US
How do I run a sql file from OSQL command prompt? how to save the command in buffer to a file and execute that later?
 
I dn't know if it is possible to do as in MySQL (for example) but you will run SQL scripts from QueryAnalyzer everytime you want to do it. Also you can make your own programs what does what instead of query analyzer. John Fill
1c.bmp


ivfmd@mail.md
 

When you say "SQL file" do you mean a text file containing T-SQL statments? If so, execute OSQL from the command prompt with the /i option.

osql /S servername /d dbname /U username /P password /i mysqlfile.sql

mysqlfile.sql is the file containing the T-SQL statements.

I'm not clear what you mean by "save the command in buffer to a file." You can type the OSQL command line in a text editor and save a BAT file to be executed later. If that's not what you need to know, please provide a little more detail. Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Thanks Guys!
what I am looking is something like this ...
when I connect thru osql i get prompt like 1> where I type my command e.g.

1>create table t1 ....
2>go

I want to save this command to a file e.g cr_t1.sql and execute it later, the way I can do it oracle as follows

SQL> create table t1
SQL> save t1.sql
Any point I can say
SQL> get t1.sql
SQL>/
/ ~ go

I think I am making some sense ...

thanks
 

OSQL doesn't have the abilty to save in the way you want. As John suggested, you can use Query Analyzer which is a much better interactive tool than OSQL. Once you've created the script in QA, you can save it and then execute it in OSQL in the future. Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top