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.
| Author |
Topic |
|
obiwaugh
Starting Member
27 Posts |
Posted - 2005-11-08 : 16:04:18
|
| In SQL Plus for Oracle, I can execute a script in a text file....the text file contains about 20 different SELECT statements.Can the same be done using SQL Server?--------------------------------I know enough to know that I don't know enough. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-11-08 : 16:12:43
|
| Yes, via osql.exe which is a command line utility.Start..Run..cmd..<enter>osql.exe -SServer1 -E -iC:\SomeScript.sqlRun osql /? to see its details or check SQL Server Books Online.Tara Kizer |
 |
|
|
obiwaugh
Starting Member
27 Posts |
Posted - 2005-11-08 : 16:52:21
|
| What can I put in the script so that the output spools to a text file?--------------------------------I know enough to know that I don't know enough. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-11-08 : 16:59:28
|
| osql.exe -SServer1 -E -iC:\SomeScript.sql -oC:\SomeOutputFile.txtOr if you are going to be running multiple scripts wrapped in a cmd or batch file then:osql.exe -SServer1 -E -iC:\SomeScript1.sql >C:\SomeOutputFile.txtosql.exe -SServer1 -E -iC:\SomeScript2.sql >>C:\SomeOutputFile.txt> says to create a new file>> says to appendTara Kizer |
 |
|
|
|
|
|