Backup or copy table with SQL
To backup/copy a table, in this case a table called “MyTable” in SQL you can do this:
SELECT * INTO [dbo].[MyTable_20110506] FROM [dbo].[MyTable]
If you just want an empty table, but with the same headings and data types then do this:
SELECT * INTO [dbo].[MyTable_20110506] FROM [dbo].[MyTable] WHERE 1 = -1
Note the name of the new table, this is so when the tables are sorted by name, then they will be listed in order of creation and associated with the corresponding table.
Advertisement