I have this batch script which runs a SQL script. I need to put today's date in the output file.
I've been told to use $(ESCAPE_DQUOTE(DATE))
but can't get it to work.
My output file still reads:
Test_$(ESCAPE_DQUOTE(DATE)).txt
Here is the script I'm trying:
echo off
sqlcmd -m 1 -S 10.108.96.211\QA832 -U Exception -P Password1 -i E:\KCM_UAT\Exception.sql -o C:\Test_$(ESCAPE_DQUOTE(DATE)).txt -W -h-1 -s " "
set /p delExit=Press the ENTER key to exit...:
I have tried escaping )
as mentioned in the comments:
echo off
sqlcmd -m 1 -S 10.108.96.211\QA832 -U Exception -P Password1 -i E:\KCM_UAT\Exception.sql -o C:\Test_$(ESCAPE_DQUOTE(DATE^)^).txt -W -h-1 -s " "
set /p delExit=Press the ENTER key to exit...:
But the output remains unchanged:
Test_$(ESCAPE_DQUOTE(DATE)).txt
I also tried double quotes on the -o
portion
CODE:
echo off
sqlcmd -m 1 -S 10.108.96.211\QA832 -U Exception -P Password1 -i E:\KCM_UAT\Exception.sql -o "C:\Test_$(ESCAPE_DQUOTE(DATE)).txt" -W -h-1 -s " "
set /p delExit=Press the ENTER key to exit...: