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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Bulk insert
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

4 Posts

Posted - 01/07/2014 :  09:34:05  Show Profile  Reply with Quote

I want to bulk insert a csv file into sql.
If the csv files are all the same this is not so exiting but the csv file is a bit strange.

If a row in the csv file begins with A than the row must be dropped.
If a row in the csv file begins with B than the row content is
10 chars for Product 20 chars for description 5 chars for quantity
If a row in the csv file begins with C than the row content is
5 chars for ordernr 5 chars for productid 5 chars for quantity

So CSV file could look like this
A 000 0 0 0 0
B0000000001product description 00005

Now it's solved to split the csv file and import each record but this is to slow so it must be done via Bulk insert and format files?

Any suggestions

Aged Yak Warrior

982 Posts

Posted - 01/07/2014 :  22:14:51  Show Profile  Reply with Quote
i think you better off using SSIS (data flow component) to cater such event.
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 01/08/2014 :  06:58:17  Show Profile  Reply with Quote
I agree to waterduck. You've tasks available inside SSIS to do all these activities like Deruved Column, Conditional SPlit etc which will provide you with required functionality straight out of the box.

SQL Server MVP
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000