How to import data to SQL Database

This guide explains how to import data into your database using SQL Database Shell.

Requirements

  • SQL Database Shell Installed: Ensure that you have the SQL Database shell properly installed on your system.

  • Database Setup: You need to have a database created. To create a new database within SQL Database using the Shell, use the command:

Terminal window
.create <database-name>

Importing Data with SQL Database Shell

  1. Select a SQL Database database.
Terminal window
.use database-name
  1. Import your file.
.import file <csv|xlsx> <file_path> <table_name>

To verify the creation of your table you can use:

Terminal window
.tables

Importing from an SQL File

To import data from an .sql file containing SQL INSERT commands, use the .read command within the SQL Database Shell. This will execute the SQL statements contained in the file and populate your database with the specified data.

Terminal window
.read <file_name>