SQL Server Management Studio includes an import wizard to help you import data from an external source.
You can import data to your SQL Server database from various other sources, including Excel spreadsheets, CSV files, and other databases such as Oracle, Access, and other SQL Server instances.
Import a CSV File
Right now we'll import a CSV file into our Albums table that we created earlier when we created a relationship.
AlbumId,AlbumName,ReleaseDate,ArtistId,GenreId
1,Powerslave,1984-09-03,1,1
2,Powerage,1978-05-05,2,1
3,Singing Down the Lane,1956-01-01,6,3
4,Ziltoid the Omniscient,2007-05-21,5,1
5,Casualties of Cool,2014-05-14,5,1
6,Epicloud,2012-09-18,5,1
7,Somewhere in Time,1986-09-29,1,1
8,Piece of Mind,1983-05-16,1,1
9,Killers,1981-02-02,1,1
10,No Prayer for the Dying,1990-10-01,1,1
11,No Sound Without Silence,2014-09-12,9,4
12,Big Swing Face,1967-06-01,4,2
13,Blue Night,2000-11-01,12,4
14,Eternity,2008-10-27,12,4
15,Scandinavia,2012-06-11,12,4
16,Long Lost Suitcase,2015-10-09,7,4
17,Praise & Blame,2010-06-26,7,4
18,Along Came Jones,1965-05-21,7,4
19,All Night Wrong,2002-05-05,3,2
20,The Sixteen Men of Tain,2000-03-20,3,2
So save the above file into a location that you'll be able to get to from the SQL Server Import and Export Wizard, and let's get started.
Import Data
Welcome to the SQL Server Import and Export Wizard
Choose a Data Source
Advanced Settings
Check the advanced settings (by clicking on Advanced in the left menu) to make sure nothing looks out of the ordinary.
Click on each column name to view the properties for that column.
In our case, you may find that all columns are listed with a data type of string [DT_STR], which could cause problems later on in the wizard.
Take this opportunity to change the data types to the following:
AlbumId
single-byte unsigned integer [DT_UI1]
AlbumName
Unicode string [DT_WSTR]
ReleaseDate
database date [DT_DBDATE]
ArtistId
single-byte unsigned integer [DT_UI1]
GenreId
single-byte unsigned integer [DT_UI1]
You can also use the Suggest Types... option. However, you may still need to modify some columns manually.
The wizard will warn you later on if it thinks there will be any issues converting data types from the source file. If that happens, you may need to come back and modify your selection here.