Timestamp suffix to a textfile | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Timestamp suffix to a textfile

Hi Gurus,
I have a job which generate a output textfile.How to suffix
timestamp to the textfile name. For example:If the textfile name is PASStestReport.txt to this
I would like to suffix timestamp and have a filename as
PASSTestReport_MMDDYYHHMM.txt. Urgent Please. Thanks & Regards raj
It depends on how you are generating the text file? using BCP, DTC etc…<br /><br />After the writing to text file you can use xp-cmdshell to rename it…<br /><br />declare @filename sysname, @sql Varchar(1000)<br />select @filename = ‘PASStestReport_’+replace( convert(Varchar(20), getdate(),101), ‘/’, ”)+ replace(convert(Varchar(5), getdate(), 10<img src=’/community/emoticons/emotion-11.gif’ alt=’8)’ />, ‘:’,”)<br />select @sql = ‘exec master..xp-cmdshell ”rename PASStestReport.txt ‘+ @filename+””<br />select @sql <br />exec (@sql)<br /><br /><br />MohammedU.<br />Moderator<br />SQL-Server-Performance.com<br /><br />All postings are provided “AS IS” with no warranties for accuracy.<br />
]]>