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 |
|
RandyLewisKemp
Starting Member
4 Posts |
Posted - 2007-10-26 : 15:04:37
|
| One of our vendor software developers created this SQL for SQL Server, but the vendor has gone. Can anyone explain what this command does. A user executes this at the command line of their machineA command file has this:osql -S (local)\SQLEXPRESS -E -i DropDB.sqlThe SQL file has this:IF EXISTS (SELECT name FROM sys.databases WHERE name = N'Caching')DROP DATABASE [Caching] |
|
|
Zoroaster
Aged Yak Warrior
702 Posts |
Posted - 2007-10-26 : 15:10:16
|
It checks for the existence of any database named Caching and drops (removes) it. Future guru in the making. |
 |
|
|
Van
Constraint Violating Yak Guru
462 Posts |
Posted - 2007-10-26 : 15:11:09
|
| It Drops the database named Caching...in other words it deletes that database if it exists. |
 |
|
|
RandyLewisKemp
Starting Member
4 Posts |
Posted - 2007-10-26 : 15:16:19
|
| Thanks everyone. Can you tell me what this command does that invokes it?osql -S (local)\SQLEXPRESS -E -i DropDB.sqlRandy |
 |
|
|
Van
Constraint Violating Yak Guru
462 Posts |
Posted - 2007-10-26 : 15:20:13
|
| It uses the osql utility to connect to the sql server and run the sql script. The -E means connect with windows authentication (I think). |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-10-26 : 15:21:04
|
| osql is a command line utility that allows you to run scripts and queries on a SQL Server. You can run osql /? from a cmd window to find out which switches are available. SQL Server Books Online has documentation on the utility too.The actual command that you there is connecting to the SQLEXPRESS on the local server using Windows Authentication and is running DropDB.sql.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
Zoroaster
Aged Yak Warrior
702 Posts |
Posted - 2007-10-26 : 15:51:31
|
quote: Originally posted by Van It uses the osql utility to connect to the sql server and run the sql script. The -E means connect with windows authentication (I think).
-E means it uses a trusted connection. Future guru in the making. |
 |
|
|
Zoroaster
Aged Yak Warrior
702 Posts |
Posted - 2007-10-26 : 15:51:31
|
quote: Originally posted by Van It uses the osql utility to connect to the sql server and run the sql script. The -E means connect with windows authentication (I think).
-E means it uses a trusted connection. Future guru in the making. |
 |
|
|
RandyLewisKemp
Starting Member
4 Posts |
Posted - 2007-10-26 : 15:58:28
|
| Thanks everyone for the quick response and excellent help.Randy |
 |
|
|
|
|
|