Link to home
Start Free TrialLog in
Avatar of VBBRett
VBBRett

asked on

Working with CSV files in C#

I would like to import information from a CSV file into a SQL Server table.  The issue that I am dealing with is I don't want to use all the fields in the CSV, only a few.  I would like to pull columns with the following header names, namecol, addresscol, agecol.  There are a total of 10 columns in the CSV file, but I only want to pull the 3 that I mentioned, so what exactly do I do to pull only the 3?  I do not want to use the index parameter like [0], so what do I do?
Avatar of dexterrajesh
dexterrajesh
Flag of India image

hi,

you can use the Import / Export wizard in SQL enterprise manager to straight away import them into a table.
when you get to Select Source Tables and Views click on the button "Edit Mappings" on the bottom left of the screen. That opens column mappings screen; on the destination column select Ignore to remove the column you don't want to import.

hope this helps
Avatar of VBBRett
VBBRett

ASKER

I have to automate code with C#.  Sorry, this solution won't necessarily help because of the process involved.  How can I import specific column names using C#?
ASKER CERTIFIED SOLUTION
Avatar of dexterrajesh
dexterrajesh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial