10

I have multiple databases created by POCO approach of website building and I want to delete those. However I get error.

Command

sqlcmd -S .\SQLEXPRESS -q "drop database aspnet-ORData-20120910180110"

Error

Msg 102, Level 15, State 1, Server MY-PC\SQLEXPRESS, Line 1
Incorrect syntax near '-'.

1 Answer 1

16

Try this:

sqlcmd -S .\SQLEXPRESS -Q "drop database [aspnet-ORData-20120910123456]"

Note the square brackets around the database name. Without them the dashes ("-") are seen as tokens instead of part of the database name and the parser will want to do math. The command parser interprets anything inside square brackets as a literal.

1
  • 1
    Note that if you want it to run the command and exit, use a capital -Q instead of lowercase -q. May 22, 2018 at 5:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .