Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 带有日期附加的Sqlcmd.bat文件sql输出_Batch File_Sql Server 2012_Sqlcmd - Fatal编程技术网

Batch file 带有日期附加的Sqlcmd.bat文件sql输出

Batch file 带有日期附加的Sqlcmd.bat文件sql输出,batch-file,sql-server-2012,sqlcmd,Batch File,Sql Server 2012,Sqlcmd,我有一个.bat文件,我计划每天凌晨1点在windows server 2008 r2上使用任务计划程序运行该文件。每次都会覆盖最终的输出文件,因此我需要在输出文件名后添加一个日期 以下是.bat文件中的code: 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

我有一个.bat文件,我计划每天凌晨1点在windows server 2008 r2上使用任务计划程序运行该文件。每次都会覆盖最终的输出文件,因此我需要在输出文件名后添加一个日期

以下是
.bat
文件中的
code

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"
我试图添加
%date%
,比如
“C:\loc\finaloutput%date%.txt”
,但是没有生成任何输出。这是我第一次做这个,所以任何指导都会很有帮助


谢谢大家!

此线程中可能存在重复的解决方案已工作!:)有人请把这个标记为答案。非常感谢。删除你的问题,因为你可以看到它是重复的。我不认为它是重复的。此线程将帮助其他用户,因为它在代码删除“----”的地方有其他信息。也许,它解决了虚线问题!