0

I would to drop remote SQL Server db via sqsh but, I don't know how does it works. I can connect to sql server with command:

sqsh -Ulogin -Ppass -Smssql2005
Kara
  • 6,115
  • 16
  • 50
  • 57
Roman Iuvshin
  • 1,872
  • 10
  • 24
  • 40

4 Answers4

0

Maybe you are using the wrong tool to connect to MS SQL Server. If you are looking to connect to MS SQL Server then you can use this code:

SQLCMD -S servername -U username -P password
OR
SQLCMD -S servername -E
PollusB
  • 1,726
  • 2
  • 22
  • 31
0

The -C argument lets you specify a query to send to the SQL Server instance.

So, I think this will do what you want:

sqsh -Ulogin -Ppass -Smssql2005 -C"DROP DATABASE MyDatabase"
bonh
  • 2,863
  • 2
  • 33
  • 37
0

Once you're connected to the server, you can drop a database with the command

drop database [DBName]

Assuming that there's no one connected to it, it should work. And if it doesn't, it'll tell you why.

Ben Thul
  • 31,080
  • 4
  • 45
  • 68
0
echo 'USE table' > script.sqsh
echo 'go' >> script.sqsh
echo 'SELECT * FROM table' >> script.sqsh
echo 'go' >> script.sqsh
sqsh -Ulogin -Ppass -Smssql2005 -i script.sqsh
mattalxndr
  • 9,143
  • 8
  • 56
  • 87