Sqlcmd .bat file sql output with date append
Sqlcmd .bat file sql output with date append 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 : code .bat SQLCMD -S ServerName -d DbName-E -i C:locscript.sql -o C:locscriptOutputtemp.txt -s"|" -W findstr /B /V /C:"----" "C:locscriptOutputtemp.txt" > "C:locfinaloutput.txt" del "C:locscriptOutputtemp.txt" I tried to add %date% like "C:locfinaloutput%date%.txt" but then nothing gets generated as output. It's my first time creating this so any guidance will be helpful. %date% "C:locfinaloutput%date%.txt" Thank you! Possible duplicate of How do I get current datetime on the Windows command line, in a suitable format for using in a filename? – Squashman Jun ...
