How to Create a Quick Table Backup using T-SQL

–OPTIONALLY CHECK FOR AND DROP THE BACKUP TABLE IF ALREADY EXISTS:
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[MY_TABLE_BACKUP_20130710]’) AND type in (N’U’))
DROP TABLE [MY_TABLE_BACKUP_20130710]
GO

–ONE LINE TABLE BACKUP:
SELECT * INTO [MY_TABLE_BACKUP_20130710] FROM [MY_ORG_TABLE]
GO
–NOTE THIS COPIES JUST DATA, NOT CONSTRAINTS OR RELATIONS

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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

%d bloggers like this: