This is part of a series of posts that help you use MS SQL server on Ubuntu 18.04. Previously we've:
- Installed Microsoft SQL Server.
- Installed Microsoft SQL Server ODBC driver and SQLCMD.
- In this part we will import data using SQLCMD.
- This builds to integrating data from Microsoft SQL Server into a data sharing layer using G8CC.
GIT and SQLCMD are typed in a terminal on Ubuntu.
How to import data into MS SQL Server.
Firstly we need data to import. For this we will use the Sakila database. You can download this from github. To do that use the following command.
git clone https://github.com/ivanceras/sakila.git
This database dump includes data for a number of different databases. To use MS SQL server data we must change director. To do this type "cd sakila/sql-server-sakila-db".
Now we have our data to import. Next we create a database and import our data.
Creating a database with SQLCMD.
To create a database using SQLCMD you type:
sqlcmd -S localhost -U SA -P [your-password] -q "CREATE DATABASE sakila;"
This creates a new database within MS SQL Server. We can now import our data. To do this we use the following command.
sqlcmd -S localhost -U SA -P [your-password] -d sakila -i sql-server-sakila-insert.sql
"sql-server-sakila-insert.sql" is a file in the "sql-server-sakila-db" folder. This command imports data into the sakila database.
Next you can learn how to extend and reuse data in a MS SQL Server using G8CC.