SQL Server – How to import a table from table backup file?

Sometimes we get a backup of individual tables and we need to restore all of them in the SQL Server database. Many times we get a big table backup which is not even open in the SSMS. Here is the solution for this, we can restore such table(s) using a batch file.

Solution:
Create a file.bat with following script.

cd\
cd C:\Program Files\Microsoft SQL Server\100\Tools\Binn
SQLCMD -S <SERVER-IP\instance-name> -U SA -P <password> -i C:\Backup\<table-name>.sql -o C:\Backup\<table-name>.log

Example:

cd\
cd C:\Program Files\Microsoft SQL Server\100\Tools\Binn
SQLCMD -S 10.211.x.x -U SA -P MyPassword -i C:\Backup\MyTable.sql -o C:\Backup\MyTable.log

Run above script using command prompt.

Parameters:

-S sever name
-U username
-P password
-i input file
-o output file.


<<Click here to see all posts>>

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Prove You Are Human Time limit is exhausted. Please reload CAPTCHA.