backup table mssql

Solutions on MaxInterview for backup table mssql by the best coders in the world

showing results for - "backup table mssql"
Victoria
08 Jul 2016
1declare @name varchar(100) = 'tableName'
2
3declare @timestamp varchar(100) =  
4 replace(cast(convert(varchar, getdate(), 126) as varchar(10)), '-', '') + '_' 
5 + RIGHT('00' +cast(datepart(hour, getdate()) as varchar), 2)
6 + RIGHT('00' + cast(datepart(minute, getdate()) as varchar), 2) + '_' 
7
8declare @query varchar(MAX) = 'select * into backup_' + @timestamp + @name  + ' from ' + @name
9
10--select @query
11exec(@query)