SQLCmd 带逗号的密码参数
SQLCmd Password parameter with comma
我们有一个 SQL 服务器,其密码包含 comma (',')
。由于我们在 SQLCmd
中使用了相同的方法,因此该过程失败了。请在下面找到我们正在使用的查询
SQLCmd -U%1 -P%2 /S%servername% /dDbName -Q"EXEC sp_test null, 'DbName', '\ProcessLog\', 'STORE'" >> %NB4%\ProcessLog.log
字符串是从不同的命令文件传递的。
But the password contains comma (','), so that the process is not able
to connect to SQL Server
有没有办法在参数中添加转义字符?尝试使用双引号 ('"'),但没有成功。任何帮助将不胜感激。
我已经找到了解决办法。由于 comma
在 password
中,comma
之后的部分被视为第三个参数,并且由于第一个参数与实际密码不匹配,因此无法建立连接.这是解决方案。非常适合我。
IF "%3" NEQ "" GOTO ThreeParm
IF "%3" == "" GOTO TwoParm
:ThreeParm
SQLCMD -U%1 -P%2,%3 /S%servername% /dTestDB -Q"EXEC sp_test null, 'TestDB', '\Folder\', 'STORE'" >> %NB4%\Folder.log
:TwoParm
SQLCMD -U%1 -P%2 /S%servername% /dTestDB -Q"EXEC sp_test null, 'TestDB', '\Folder\', 'STORE'" >> %NB4%\Folder.log
我们有一个 SQL 服务器,其密码包含 comma (',')
。由于我们在 SQLCmd
中使用了相同的方法,因此该过程失败了。请在下面找到我们正在使用的查询
SQLCmd -U%1 -P%2 /S%servername% /dDbName -Q"EXEC sp_test null, 'DbName', '\ProcessLog\', 'STORE'" >> %NB4%\ProcessLog.log
字符串是从不同的命令文件传递的。
But the password contains comma (','), so that the process is not able to connect to SQL Server
有没有办法在参数中添加转义字符?尝试使用双引号 ('"'),但没有成功。任何帮助将不胜感激。
我已经找到了解决办法。由于 comma
在 password
中,comma
之后的部分被视为第三个参数,并且由于第一个参数与实际密码不匹配,因此无法建立连接.这是解决方案。非常适合我。
IF "%3" NEQ "" GOTO ThreeParm
IF "%3" == "" GOTO TwoParm
:ThreeParm
SQLCMD -U%1 -P%2,%3 /S%servername% /dTestDB -Q"EXEC sp_test null, 'TestDB', '\Folder\', 'STORE'" >> %NB4%\Folder.log
:TwoParm
SQLCMD -U%1 -P%2 /S%servername% /dTestDB -Q"EXEC sp_test null, 'TestDB', '\Folder\', 'STORE'" >> %NB4%\Folder.log