Monday, November 03, 2008

loading csv file to SQL Server

loading csv file to SQL Server

CREATE TABLE CSVTest
(FirstName VARCHAR(40),
No1 INT,No2 INT,No3 INT,No4 INT)
GO

select * from CSVTest


BULK
INSERT CSVTest
FROM 'd:\Tesing.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO


select * from CSVTest

If there is a error in a particular row that row will not be added.
rest of the rows will be loaded into sql server.

.csv file
vijay,20,19999,90000,8
Jagadeesh,9,111,60000,9

No comments: