Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 How to validate text file data using bulk insert

Author  Topic 

SAG2011
Starting Member

1 Post

Posted - 2012-05-17 : 02:04:18
Hi,
I want to import data from text file.format of file is as follows:
date,id,unit_number,Quantity
05/17/2012,1,117,100
05/16/2012,2,118,100

I am using bulk insert do it.like this

BULK
INSERT vw_bulk_insert_test
FROM '\\server\c$\csvtext.txt'--\\server\SQLEXPRESS\csvtest.txt'
WITH
(FIRSTROW=2,
check_CONSTRAINTS,
FIELDTERMINATOR = '~',
ROWTERMINATOR = '\n'
)
GO

But before insert I want to validate values of each column.Like if second row will have values of all fields except unit_number then it should throw an error that unit_number value is missing.And it should not insert ant data after that.

Please guide me on the same.
Thanks in advance.
   

- Advertisement -