SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

IPFL
Starting Member

Belgium
4 Posts

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

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
C000020000300004
...

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

waterduck
Aged Yak Warrior

Malaysia
965 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.
http://technet.microsoft.com/en-us/library/ms137612(v=sql.105).aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 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
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.06 seconds. Powered By: Snitz Forums 2000