7

I am using SQL SERVER 2005 Express. I can delete the database from the query analyzer, what you call Mgmt Studio (ssmsee) by providing double quotes to the database name and things get done;

Drop Database "14data" Go

and the db is gone,

but sqlcmd gives error on 14 (Msg 102 Level 15 State 1 Incorrect sysntax near 14 ) May be it considers numeric part as some other thing and not the database name, I tried with N'',"", $(), also tried variables and executing correct sql script files (that ran correctly on mgmt studio) but it gives the same error at the exact same place.

Has any1 ever deleted a database with alphanumeric db name from SQLCMD ?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
maqk
  • 313
  • 2
  • 7
  • 18

2 Answers2

11

You may be able to enclose it [] brackets.

e.g.

drop database [14data] go
Sdaz MacSkibbons
  • 27,668
  • 7
  • 32
  • 34
  • Thanks! This also applies to when your database name looks like a path (e.g. C:\USERS\Admin\DESKTOP\EXAMPLE.MDF) – Jonny Aug 26 '13 at 10:10
5

for special characters use [ ] square brackets. It should be used while dealing with keywords,special characters for column names,table names and database names and as well.

Drop Database [14data]
Whimsical
  • 5,985
  • 1
  • 31
  • 39