Technical Article

SQL Server Shortcut to take Table Backup

,

SQL Short keyboard option helps to take table backup by pressing the shortcut keys.

1. Create the procedure "sp_tablebackup" as system stored procedure on master database.

2. Create shortcut key on keyboard shortcut options(Tools>Options>Keyboard>place the created system stored procedure "sp_tablebackup" on any of the short cut key)and press ok.

3. For example if the system stored procedure is added on shortcut key "CTRL+3",we can take the table backup by selecting any tables and by pressing "CTRL+3" option.

4. This option takes table backup with the name "Tablename_currentdate", and this backup table will be stored on the same database(if required we can save it on other locations too).

CREATE PROC Sp_TableBackup(@tblname NVARCHAR(100))    
AS    
DECLARE @SQL NVARCHAR(MAX)    
DECLARE @DT VARCHAR(10)    
SELECT @DT = REPLACE((CONVERT(VARCHAR(10),GETDATE(),110)),'-','_')     
SET @SQL='SELECT * INTO '+@tblname+'_'+@DT + ' FROM '+@tblname    
PRINT @SQL    
EXECUTE(@SQL)

Rate

5 (2)

You rated this post out of 5. Change rating

Share

Share

Rate

5 (2)

You rated this post out of 5. Change rating