SQLCMD - 尝试删除带有字母数字名称'14Data'的数据库会出现语法错误

时间:2021-12-28 15:38:03

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;

我正在使用SQL SERVER 2005 Express。我可以从查询分析器中删除数据库,你可以通过为数据库名称提供双引号来完成所谓的Mgmt Studio(ssmsee);

Drop Database "14data" Go

删除数据库“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.

但sqlcmd在14上给出了错误(Msg 102 Level 15 State 1 Incorrect sysntax 14附近)可能它认为数字部分是其他东西而不是数据库名称,我试过N'',“”,$(),也尝试过变量和执行正确的sql脚本文件(在mgmt studio上正确运行)但它在完全相同的位置给出了相同的错误。

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

有没有人从SQLCMD删除了带有字母数字数据库名称的数据库?

2 个解决方案

#1


11  

You may be able to enclose it [] brackets.

您可以将[]括号括起来。

e.g.

例如

drop database [14data] go

#2


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]

#1


11  

You may be able to enclose it [] brackets.

您可以将[]括号括起来。

e.g.

例如

drop database [14data] go

#2


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]