SQL command mode SQL SERVER - unable to Print

2019-08-28 08:00发布

I am trying to run these commands and I am getting below result. A single quote ('GetDetailsToSendApprovalMail.sql ) keeps appearing in o/p, now matter what I try. Please let me know what I am doing wrong ?

:setvar ScriptPath 'C:\ProjectWork\DatabaseFiles\DEV\23OctScriptDev\'

:setvar SQLFile 'GetDetailsToSendApprovalMail.sql'


 PRINT $(ScriptPath)'GetDetailsToSendApprovalMail.sql'
 PRINT $(ScriptPath)$(SQLFile)

output:

C:\ProjectWork\DatabaseFiles\DEV\23OctScriptDev\'GetDetailsToSendApprovalMail.sql C:\ProjectWork\DatabaseFiles\DEV\23OctScriptDev\'GetDetailsToSendApprovalMail.sql

2条回答
Melony?
2楼-- · 2019-08-28 08:30

You should concatenate the strings using +:

:setvar ScriptPath 'C:\ProjectWork\DatabaseFiles\DEV\23OctScriptDev\'

:setvar SQLFile 'GetDetailsToSendApprovalMail.sql'

 PRINT $(ScriptPath)+'GetDetailsToSendApprovalMail.sql'
 PRINT $(ScriptPath)+$(SQLFile)
查看更多
劳资没心,怎么记你
3楼-- · 2019-08-28 08:41

Please use + as concatenation operator like below:

PRINT $(ScriptPath)+$(SQLFile)
查看更多
登录 后发表回答