Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How can I backup one table to file

Author  Topic 

jooorj
Posting Yak Master

126 Posts

Posted - 2011-08-23 : 22:06:12
How to backup a table to a file in MS SQL Server 2008

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-08-23 : 22:28:05
You can't. There isn't a "table backup" function in SQL Server. You can only backup the entire database using the BACKUP command.

The closest probably is to use BCP to export the data out and SSMS to script out the table schema.




KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2011-08-23 : 22:49:25
Or if your table belongs to certain filegroup and the filegroup contains only that table, you can backup the filegroup. As a result, only your table will be backed up.

Harsh Athalye
http://www.letsgeek.net/
Go to Top of Page

mariana
Starting Member

2 Posts

Posted - 2011-08-24 : 06:43:56
There isn't any table back up in SQL Server.
unspammed
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2011-08-24 : 07:58:03
If you just want to take a "safe copy" of your table, before making a critical change, then you can do:

SELECT * FROM MyTable INTO TEMP_MyTable_yyyymmdd

or

SELECT * FROM MyTable INTO MyTempDatabase.dbo.TEMP_MyTable_yyyymmdd

if you have a suitable MyTempDatabase you can store it in instead - e.g. if table is large and you don;t want to "pollute" the main database, or extend its log files.
Go to Top of Page

gwilson67
Starting Member

42 Posts

Posted - 2011-08-25 : 00:52:43
There's a few ways of 'skinning this cat'

1) Put the table on its on filegroups and then backup that filegroup.
2) Export the contents of the table out to a file(you can do this from the management studio).
3) Copy the table to another database


Greg
http://www.freewebstore.org/tsqlcoderepository
Powerful tool for SQL Server development
Go to Top of Page
   

- Advertisement -