The below query gives unique date and time.
declare @sql varchar(255)
declare @dbname sysname='dssp1'
select @sql=' BACKUP DATABASE '+ @dbname+' TO DISK = ''C:\'+@dbname+'_'+REPLACE(CAST(CONVERT(DATE,GETDATE())as VARCHAR(10)),'-','')+'_'+REPLACE(CAST(CONVERT(TIME,GETDATE()) AS VARCHAR(8)),':','')+'.BAK'''
print @SQL
exec (@sql)
--Prashanth
No comments:
Post a Comment