开发者

concatenation in windows batch file

开发者 https://www.devze.com 2023-04-12 02:45 出处:网络
Here is the code in my batch file set startdate=\"9/1/2011\" set enddate=\"10/31/2011\" sqlcmd -Q \"exec mysp \'%startdate%\', \'%enddate%\'\"

Here is the code in my batch file

set startdate="9/1/2011"
set enddate="10/31/2011"

sqlcmd -Q "exec mysp '%startdate%', '%enddate%'"

I want to execute the c开发者_C百科ommand in SQL Server:

exec mysp '9/1/2011', '10/31/2011'


Well, you haven't exactly told us what's going wrong but I'm guessing the double quotes arond the dates are being included in the command, as per:

C:\Users\Pax> set startdate="9/1/2011"

C:\Users\Pax> echo %startdate%
"9/1/2011"

C:\Users\Pax> set startdate=9/1/2011

C:\Users\Pax> echo %startdate%
9/1/2011

Try removing them.

0

精彩评论

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

关注公众号