0
Posted on 2:23 AM by prajeesh and filed under ,
This is one of the common requirement for DBA's or Programmers,How to import a .csv file into SQL Server data base,we can do this by bulk insert sql command ,let me explain the steps to do this.










suppose this is our .csv file and we want to import address data from this file(note:fields are separated by commas).
Next step is to create a table in your database for importing

CREATE TABLE address(name varchar(50),place varchar(50),zipcode int)

GO
in the next step we will import data from csv file,open your sql server Query Analyzer and give query as shown in the figure below










the query is
BULK INSERT address FROM 'C:\address.csv'
WITH(FIELDTERMINATOR = ',',ROWTERMINATOR = '\n'
)
GO


you can check the data using SELECT command(select * from address)

enjoy




Shout it kick it on DotNetKicks.com
0
Responses to ... Importing .CSV Files into SQL Server database using BULK INSERT