Friday, December 5, 2025

.::: Backup & restore table SQL Server Using bcp & SQL CMD like MariaDB :::.

 


A. Source (backup data )

1. check table barang 
  


2. Backup data as table using bcp 

bcp teguhth.dbo.barang out "C:\Backup\barang.txt" -c -t, -S localhost -U usertest -P passwordsql

bcp barang out "C:\Backup\barang.txt" -c -t, -S localhost -U usertest -P passwordsql -d teguhth

  

3. export / record structure table using export script or using save scrip. after check script 

 

B. Destination (Restore data)


1. create table as same as source address or using import script 

sqlcmd -S MSSQL -U usertest -P passwordsql -d bcpdb -i C:\Backup\barang_sqlschema.sql

2. import data using bcp 

bcp bcpdb.dbo.barang in "C:\Backup\barang.txt" -c -t, -S localhost -U usertest -P passwordsql
bcp barang in "C:\Backup\barang.txt" -c -t, -S localhost -U usertest -P passwordsql -d bcpdb
 

3. check result table 
select * from bcpdb.dbo.barang ; 

 

No comments:

Post a Comment

Popular Posts