Backup a single table with its data from a database in sql server 2008

后端 未结 10 1656
青春惊慌失措
青春惊慌失措 2020-12-02 07:18

I want to get a backup of a single table with its data from a database in SQL Server using a script.

How can I do that?

相关标签:
10条回答
  • 2020-12-02 07:50

    To get a copy in a file on the local file-system, this rickety utility from the Windows start button menu worked: "C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\DTSWizard.exe"

    0 讨论(0)
  • 2020-12-02 07:53

    Another approach you can take if you need to back up a single table out of multiple tables in a database is:

    1. Generate script of specific table(s) from a database (Right-click database, click Task > Generate Scripts...

    2. Run the script in the query editor. You must change/add the first line (USE DatabaseName) in the script to a new database, to avoid getting the "Database already exists" error.

    3. Right-click on the newly created database, and click on Task > Back Up... The backup will contain the selected table(s) from the original database.

    0 讨论(0)
  • 2020-12-02 07:59

    You can create table script along with its data using following steps:

    1. Right click on the database.
    2. Select Tasks > Generate scripts ...
    3. Click next.
    4. Click next.
    5. In Table/View Options, set Script Data to True; then click next.
    6. Select the Tables checkbox and click next.
    7. Select your table name and click next.
    8. Click next until the wizard is done.

    For more information, see Eric Johnson's blog.

    0 讨论(0)
  • 2020-12-02 07:59

    Put the table in its own filegroup. You can then use regular SQL Server built in backup to backup the filegroup in which in effect backs up the table.

    To backup a filegroup see: https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/back-up-files-and-filegroups-sql-server

    To create a table on a non-default filegroup (its easy) see: Create a table on a filegroup other than the default

    0 讨论(0)
提交回复
热议问题