April 20, 2012 at 5:52 pm
After playing in Server management for a hour or so and Google for a while more I decided maybe someone on here may know the answer. so here it goes.
I have a LOT of .txt files that i need to bring into a database. right now i have 5 access databases doing it. it isn't hard it is just bringing them in then appending them. that being said there is a difficulty. these files have VERY specific character counts for different data. for example 1-13 is last name, 14-20 is first name...and such. I have access pulling these tables in for each month of the year for all 5 databases. it is time consuming and yet the only way i know how to pull in the data, separate it into its distinct pieces.
so is it possible to bring it into SQL and separate it into its distinct pieces?
April 20, 2012 at 6:14 pm
This is a job for SSIS.
April 20, 2012 at 8:48 pm
andersg98 (4/20/2012)
This is a job for SSIS.
+1 however you could also bulk insert into a staging table and use substring functions to break your data into the correct columns and insert into your table (or another staging table).
and the answer is always it depends with something this vague.
For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]
Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
Jeff Moden's Cross tab and Pivots Part 1[/url]
Jeff Moden's Cross tab and Pivots Part 2[/url]
April 24, 2012 at 4:21 am
April 24, 2012 at 9:25 am
ok i will look into using SSIS for this. Thank you for your help. It looks like i will be learning something new today.
April 24, 2012 at 10:26 pm
April 26, 2012 at 10:56 am
ok I was able to import one table!!!! awesome!:-D it shows up in the manager studio db and everything!
Now the only thing is how do I import more like it without having to go through each file and set the parameters and things again? I have looked for ways to set it to a different flat file but each time i try and set up a "new connection" it says columns haven't been defined for the source. I cant seem to figure out how to attach screen prints though. 🙁
Thank you for your help again...sorry I don't know more unfortunately.
This is an amazing tool! I am hoping to get to know it better...in time though. Working full time with school full time means I will be slow going. 🙁
April 26, 2012 at 10:08 pm
April 27, 2012 at 3:48 am
slunt01 (4/26/2012)
ok I was able to import one table!!!! awesome!:-D it shows up in the manager studio db and everything!Now the only thing is how do I import more like it without having to go through each file and set the parameters and things again? I have looked for ways to set it to a different flat file but each time i try and set up a "new connection" it says columns haven't been defined for the source. I cant seem to figure out how to attach screen prints though. 🙁
Thank you for your help again...sorry I don't know more unfortunately.
This is an amazing tool! I am hoping to get to know it better...in time though. Working full time with school full time means I will be slow going. 🙁
Looks like your learning and loving it 🙂
I'm assuming you are using SSIS? If you are then take a look at the Connection Type mentioned here:
http://msdn.microsoft.com/en-us/library/ms137830(v=sql.100).aspx
April 29, 2012 at 5:17 pm
andersg98 (4/20/2012)
This is a job for SSIS.
Oh, horse muffins! 😛 BULK INSERT with a format file makes this a simple T-SQL task.
--Jeff Moden
Change is inevitable... Change for the better is not.
May 3, 2012 at 4:09 pm
ok what is a bulk insert?
See i told you i was new.
It seems like there is a million ways to do one thing.
May 3, 2012 at 4:38 pm
slunt01 (5/3/2012)
ok what is a bulk insert?See i told you i was new.
It seems like there is a million ways to do one thing.
Here is the MSDN article on it http://msdn.microsoft.com/en-us/library/ms188365.aspx
Bulk insert allows you to insert from a file and several other sources. you can break your string's down while you insert into a table using substring functions or with the format file like Jeff mentioned.
For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]
Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
Jeff Moden's Cross tab and Pivots Part 1[/url]
Jeff Moden's Cross tab and Pivots Part 2[/url]
May 18, 2012 at 9:04 am
Still working on this. It is hit and miss I think I am getting closer.
I looked at doing a bulk insert but I couldn't figure out the code to do it. (I have 60 columns in the txt file).
I have looked at the code for format files and I have tried several ways. I will be trying to do it again today. If all else fails I know I can use Access to get it into the format I need and then import from there. 🙂
Thank you all for your help.
May 18, 2012 at 9:36 am
You can run BCP without a format file and it will help you create one, guessing at the columns.
May 18, 2012 at 9:45 am
If the file is a delimited file and is in good and reasonable shape, neither BCP or Bulk Insert need a format file.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 15 posts - 1 through 15 (of 29 total)
You must be logged in to reply to this topic. Login to reply