Backup sql table using BCP (BULK COPY PROGRAM)
Export:
Use below command to export data.you can use any extension *.dat or *.txt
bcp DBA.dbo.EMP_DETAILS out C:\Users\Documents\DBA.dbo.EMP_DETAILS.dat -n -T
Note:-
OUTPUT:-
File Location:- C:\Users\Documents\
Import:
To perform import you need have to create same table structure to destination.
Step 1: Right click on table --> Properties-->Script Table as-->Create To-->New Query Window
Output : Table structure
Step 3: Execute table script to destination. Change the table name if required.
- You must have bulk import / export privileges or SYSADMIN access.
- -n denotes native SQL data types, which is key during restore
- -T denotes that you are connecting to SQL Server using Windows Authentication, in case you want to connect using SQL Server Authentication use -U<username> -P<password>
File Location:- C:\Users\Documents\
Import:
To perform import you need have to create same table structure to destination.
Step 1: Right click on table --> Properties-->Script Table as-->Create To-->New Query Window
Output : Table structure
Step 3: Execute table script to destination. Change the table name if required.
Step 4: Now restore table backup which we have taken on path C:\Users\Documents\
*.dat file
*.txt file
Final Output of export & Import
Thats all :)
More:
No comments:
Post a Comment