How do I name the output textfile to YYYYMMDD based on the system date?

寵の児 提交于 2019-12-06 03:06:38
Andreas Rohde

Tried it under Windows 7 Premium (German), may be dependent upon OS and Local Time Format.

sqlcmd -S DataBBB -i c:\scripts\followup.sql 
                            -o %date:~-4%_%date:~3,2%_%date:~0,2%.txt -s; 

You have to edit this part for your system

%date:~-4%_%date:~3,2%_%date:~0,2%.txt

The statement used the command line internal %date% - variable with the extension :~start,length. So you can create the filename with different parts from the date- variable.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!