bcp "select * from (DBNAME).dbo.qt_trace where User_1 is not null" queryout c:\%date:~6,4%%date:~0,2%%date:~3,2%%time:~0,2%%time:~3,2%%time:~6,2%.csv -S"KUNWSQL1\TEST" -Uusr1 -Ppwd1 -c -t"," -r"\n" pause