October 15, 2007 at 3:07 pm
I have created a daily job on SQL Server2000 that uses the osql utility.
Here is my statement:
osql -E -S Servername -i d:\query.sql -o d:\output.txt
Since this runs daily, I want to name the output.txt to yesterday's date so it is unique. (example: 20071014.txt)
Does anyone have any suggestions on how this can be done?
Thanks in advance!
October 15, 2007 at 3:37 pm
the convert() function has some special formats when converting date time...the format 112 is what you are looking for:
declare @cmd varchar(255)
SELECT CONVERT(VARCHAR,getdate(),112) + '.txt'
SELECT @cmd='osql -E -S Servername -i d:\query.sql -o d:\' + CONVERT(VARCHAR,getdate(),112) + '.txt'
print @cmd
results:
osql -E -S Servername -i d:\query.sql -o d:\20071015.txt
Lowell
October 16, 2007 at 7:49 am
That worked perfect. Thanks alot!:D
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply