I've been battling for hours to add a date to a CSV name: For brevity, Im just taking the first character of the date here.
In SQL Command, this works:
sqlcmd -S localhost -d master -E -W -w 999 -s "," -Q "SELECT D.* FROM sys.databases D" -o "C:\sqlcmd%date:~1,1%.csv"
But when I try to use that exact same code inside the step of a job, the filename is
sqlcmd_%date
I cant run xp_commandShell, is there a way to get the dynamic date working in SQLCmd please? I've read through so many articles, eg.