user983965
user983965

Reputation: 1121

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" -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,

Upvotes: 2

Views: 6986

Answers (2)

gbn
gbn

Reputation: 432657

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.

Upvotes: 4

Dave Hogan
Dave Hogan

Reputation: 3221

Try wrapping ALM.10.2.33.1 in square brackets:

[ALM.10.2.33.1]

Upvotes: 1

Related Questions