Rename a File Name with Timestamp Appended





declare @dt varchar(15)
select @dt=format( getdate(),'yyyyMMdd_HHMMss')
--Select   Replace( Replace(Replace(Convert(varchar(19), getdate(),126),'-',''),':',''),'T','_')
declare @newname varchar(100)
Set @newname= @dt+'mypdf.txt'
declare @s varchar(200)  
Set @s =  'Rename C:\temp\mypdf.txt ' + @newname

exec xp_cmdshell @s
 
 
Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s