I have a .bat file that I have scheduled to run daily at 1am using task scheduler on a windows server 2008 r2. The final output file gets overwritten every time so I need to add a date after the output file name.
Here is the code
in .bat
file :
SQLCMD -S ServerName -d DbName-E -i C:\loc\script.sql -o C:\loc\scriptOutputtemp.txt -s"|" -W
findstr /B /V /C:"----" "C:\loc\scriptOutputtemp.txt" > "C:\loc\finaloutput.txt"
del "C:\loc\scriptOutputtemp.txt"
I tried to add %date%
like "C:\loc\finaloutput%date%.txt"
but then nothing gets generated as output. It's my first time creating this so any guidance will be helpful.
Thank you!