开发者

SQLCMD Incorrect syntax near '.'

When executing a stored procedure using SQLCMD with the following parameters:

. sqlcmd -S $sql_server -U $sql_usr -P $sql_pwd -d $sql_db -Q "EXEC $storedProc $dateVariable, $regionType, ALM.10.2.33.1开发者_如何学C" -V 1 -b

The following message is received:

Incorrect syntax near '.'.

If I pass ALM_10_2_33_1 instead of ALM.10.2.33.1, the stored procedure is executed perfectly.

Thanks,


Delimit the parameter correctly with single quotes

"EXEC $storedProc $dateVariable, $regionType, 'ALM.10.2.33.1'"

SQL Server has quirk that allows (var)char parameters to be specified without delimiters if they don't contain certain characters like ..

You can see it in MSDN

EXEC sp_addserver <'new_name\instancename'>, local

But if you check sp_addserver, @local is varchar(10), and 'LOCAL' is mentioned as the value required.


Try wrapping ALM.10.2.33.1 in square brackets:

[ALM.10.2.33.1]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜