467,915 Members | 1,198 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,915 developers. It's quick & easy.

import text file in sql 2005

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
  • viewed: 2484
Share:
2 Replies
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 2GB
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.

Similar topics

1 post views Thread by jean.rossier | last post: by
3 posts views Thread by Joost | last post: by
2 posts views Thread by David Berry | last post: by
1 post views Thread by Shaun Harwood | last post: by
2 posts views Thread by musicloverlch | last post: by
3 posts views Thread by Davy B | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.