Importing data from the command line

You can automate the data import process using the command line. This option can be very useful if you need to import data to the same table or view quite often. In this case, you can create a template file using Data Import Wizard, where all import settings will be saved, and perform import by specifying the name of this file in the command line instead of going through all wizard pages again and again. Note that some parameters like connection, input file, and some others can be specified directly in the command line. In this case, the values of these parameters specified in your template file will be overridden.

Note

You cannot import data into a new table using the command line.

To create a template file:

1. Open Data Import wizard.

2. Go through all wizard tabs and specify necessary information and settings.

3. When all necessary settings were made, click the Save Template button on any of the wizard’s tabs.

Note

  1. The generated file does not contain password information for security purposes. If the Save Password option is checked for the selected connection in dbForge Data Pump for SQL Server, you should not do anything regarding the password. If it is not, then you should define the password with the help of the /password option.
  2. It is not necessary to click the Import button in the wizard and perform the import process itself to create a template file.

To import data through command line:

1. To open Command Prompt, press Win+R and type cmd in the Open line.

2. Type a path to the datapump.com file located in dbForge Data Pump for SQL Server installation folder on your PC, and press the SPACE key:

C:\Program Files\Devart\dbForge SQL Tools Professional\dbForge Data Pump for SQL Server\datapump.com

Note

It is not necessary to specify the extension of the datapump file with the .com extension.

3. Specify the operation you want to perform (data import) and the template file:

/dataimport /templatefile:<filepath>

4. Type all other arguments you need.

5. Press ENTER to run the process.

The full command may look like as follows:

"C:\Program Files\Devart\dbForge SQL Tools Professional\dbForge Data Pump for SQL Server\datapump.com" /dataimport /templatefile:"C:\Import\sample_template.det"

Note

To run the Command Line in Windows 10:

From the Desktop Mode

  • Move the mouse cursor to the exact lower left corner until the desktop shortcuts menu appears.
  • Right-click to see the shortcut menu and than click Run.

From the Charms Bar

  • Move your mouse to the upper right corner until the Charms Bar appears.
  • Select Apps from the list and type ‘run’ in the search box.
  • Click Run from the search results.

Use Windows + R Shortcut Keys

  • In desktop mode, press the Windows + R keys, to show the Run command line.
  • In the window that opens, type cmd and press Enter.

See also How to Build a Job to Import Multiple CSV files into a SQL Server Database

If you want to learn how to import data to SQL Server database with dbForge Data Pump, feel free to watch this video.