skip to main |
skip to sidebar
0
Posted on 2:23 AM by prajeesh and filed under
Data Base,
SQL Server
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 importingCREATE TABLE address(name varchar(50),place varchar(50),zipcode int)GOin 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 isBULK INSERT address FROM 'C:\address.csv' WITH(FIELDTERMINATOR = ',',ROWTERMINATOR = '\n'
)
GOyou can check the data using SELECT command(select * from address)enjoy
Post a Comment