Saturday 4 February 2012

Import CSV Data into Sql Server Table

Getting a CSV file into a SQL Server table?

Found an even easier way to do it...

CREATE TABLE TelephoneNumbers
(TelephoneNumber NVarChar(15))
GO

BULK INSERT TelephoneNumbersFROM 'c:\TelephoneNumbers.csv'
WITH
(
 FIELDTERMINATOR = ',',
 ROWTERMINATOR = '\n'
)
GO

The code is self explanatory; I was surprised how easy it was!'

No comments:

Post a Comment