Hi everyone. Today you will be reading about importing data into Microsoft SQL server. Sometimes when data analysts, data scientists or data enthusiasts are working on data there are certain operations you may want to carry out – to analyze and dissect – that you may not be able to do using popular tools like Tableau or Excel. I’ve found SQL to be very direct at dealing with data and helping me find answers to questions I’m asking or problems I’m trying to solve.
This brings into view the procedure of importing data into Microsoft SQL Server. The reason I chose Microsoft SQL Server for today’s article is because it is a very common SQL data warehouse/database, it’s been around for quite a while, and very simple to use.
The first thing to do is to create a new database if you want to work on the data in a different database and not an existing one. To do that right click on Databases at the top left of the Microsoft SQL Server user interface and click on the option New Database.
A window opens up where you can type the name of your database. Then, at the lower right-hand side of the window, there is an Add button to click to add that new database to Microsoft SQL Server.
If the Example Database doesn’t show up under the file area Databases, then right click on the Refresh button. After that, the new database should be visible.
Now you have created your new database!
The next step is to import your dataset into SQL Server. It could be in the form of an Excel file or a text file. Right-click on the Example Database, go to Tasks, then go to Import Data. The Import Flat File option can be used when importing files in different formats, like the .csv format, .asc format, .txt format. For this example, we’ll be using the Flat File option.
After clicking on the Flat File option this screen shows up.
After clicking on Next, another screen pops up where you can choose what file you want to upload.
Click on Next and the Preview Data page shows up. Here you can click on Modify Columns to create Primary Keys for the dataset in question. You can also change the data types of all the columns or features in the dataset. There’s also an option to Allow Null Values in the dataset.
After this process, click on Next to take you to the Summary Page. This displays a summary, in essence of the SQL Server name, the name of the database that the file will be imported into, the table name of the file, (which can be changed from one name to another in the Specify Input File section of the import wizard), and the location of the file on your computer where it’s imported from. Click on Finish and the file and its contents will be initialized into the Microsoft SQL Server, then click on Close.
The last step is to go to Databases, then Example Database, which is our database for this article, then right-click on Tables, under the database, then click Refresh out of all the options. This is a simple way to import data into Microsoft SQL Server. Thank you.