How to take backup of table in sql server using generate scripts.

Backup Types are dependent on Recovery Model. Every recovery model lets you back up whole or partial SQL Server database. 
There is no particular command to take table level backup like we have for full backup & log (Backup database [DB_name] to disk=C:/....). 
Below is the workaround we can use to take backup of table. This approach generates scripts (scripts.sql) of table including data which we can execute on other DB or other instance.

Step 1: Right click on database --> Task-->Generate Scripts.




Step 2: Below window will open . click Next



Step 3: Click on select specific database object to enable Tables or User tabs.
              Select table name of which you want to take backup
              Click Next



Step 4:Select Save scripts to a specific location & put location in File Name.
            Click Next


Step 5:  Click on advance. below window will pop up. 
              Click on Types of data to script & choose appropriate option. If you want data only then choose data, In our case we 
              have choosen schema and data.
              Click OK


Note :- We can enable others option like script login , object level permission etc. By Default it is false, Make it true to script.

Step 6: Next step show you summary what ever you have selected.


Step 7: This step gives you summary of successful actions.


Step 8:- Go to path where you have saved script and open it.

 ------------------------------------------------------------------------------------------------------------

Now you can consider this as dump of table. This script you can use for other DB's or other instance.
Only you need have to open script , copy data , paste it on query window & run. 
You can see all 5 records has been affected to new table EMP_DETAILS1.




Thats it. :) 

More:

No comments:

Post a Comment