Wednesday, 29 June 2011

Deleting a database with sqlcmd

sqlcmd -s <servername> -q "DROP DATABASE <database name>"
OR
sqlcmd -s ./<sqlserver instance name> -q "DROP DATABASE <database name>"

Examples:
sqlcmd -s dbserver -u username -p password -q "DROP DATABASE products"
sqlcmd -s localhost -q "DROP DATABASE products" 
sqlcmd -s ./MSSQLSERVER -q "DROP DATABASE products" 



5 comments:

Anonymous said...

Should that be an upper case S for the server name/instance, ie. -S?

Anonymous said...

U and P should be upper also.

Anonymous said...

Does it set SINGLE_USER mode? Does it work if DB is busy?

Leslie Lim said...

This is really an interesting topic. Congratulations to the writer. I'm sure a lot of readers having fun reading your post. Hoping to read more post from you in the future. Thank you and God bless!


Rica
www.imarksweb.org

joy said...

Hi, I hope you have a good day. Thank you for inspiring us. You bring joy to our face.Visit my site if you have time.

kieth

www.n8fan.net