By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,659 Members | 1,714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,659 IT Pros & Developers. It's quick & easy.

import text file in sql 2005

P: 43
i have a text file. I want to import it in table in sql 2005.that table has 8 fields.whn importing text file first 4 fields are in first line and next 2 in 2nd and rest 2 in last line. I want all 8 fields in one line. plz guide.
Dec 1 '08 #1
Share this Question
Share on Google+
2 Replies


P: 4
Since you are using SQL 2005, once way (where you would have more control over the import) is to use write a CLR stored procedure, that will read the file using a StreamReader that loops through the file and treats each 3 lines (and multiples thereof) as a single record and inserts into the table.
If you go this way, remember you can use Context Connection = True to refer to the database that you are calling to CLR SP from...

Hope this helps
-Shiva
mycodetrip.com
Dec 1 '08 #2

ck9663
Expert 2.5K+
P: 2,878
What's the text file type? Delimited? Fixed?

-- CK
Dec 2 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.