SQL命令模式SQL SERVER-无法打印

时间:2018-11-28 14:12:20

标签: sql-server sql-server-2008

我正在尝试运行这些命令,但结果低于预期。单引号('GetDetailsToSendApprovalMail.sql )继续出现在o / p中,现在不管我尝试什么。请让我知道我在做什么错吗?

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

:setvar SQLFile 'GetDetailsToSendApprovalMail.sql'


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

输出:

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

2 个答案:

答案 0 :(得分:0)

请使用+作为连接运算符,如下所示:

PRINT $(ScriptPath)+$(SQLFile)

答案 1 :(得分:0)

您应使用+连接字符串:

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

:setvar SQLFile 'GetDetailsToSendApprovalMail.sql'

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