SSMS tool is used for writing queries. Apart from this, it is very helpful tool to import the CSV data into SQL Server.
Suppose we have a CSV file like this which is having double quotes and comma separated and it has headers also.
To Load this file into SQL Server, We can import using the below.
Database --> Tasks --> Import Data
It opensup the wizard.
Click next. Select Flat File as Data Source and select the file path,
Format : Delimited. In the above CSV the delimiter is comma.
Header Row Delimeter : It is comma
Header rows to skip : We have headers in the csv file so it should be zero
Select check box column names in the first row data
Click on columns to preview
If you want to change anything, use the advanced tab
To preview rows clik on preview.
Click next and select SQL native client and SQL server instance name. We windows or SQL based on the usage. Select database.
Click next and sleect target name. We can rename the table also if it new table. Since this table not exist in db ,SQL will create automatically.
Run immediately to run the package.
Click Finish to start the package.
The package run completed successfully.
We can see verify the table data by running the select in the target database.
No comments:
Post a Comment