Solved

How do you import fixed width files into SQL Server

Posted on 2008-09-30
6
335 Views
Last Modified: 2012-05-05
I have about 20 fixed length text files named as:

crt.001
crt.002
...
crt020

How can I cycle through all 20 files and import the data into SQL Server tables using T-SQL.  I may have to convert character values from the fixed text files to some date types or booleans also.l

Thanks
Nick
0
Comment
Question by:countyprob
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 29

Accepted Solution

by:
QPR earned 500 total points
ID: 22611835
http://www.sqlis.com/55.aspx

"Looping over files with the Foreach Loop"
0
 
LVL 1

Author Comment

by:countyprob
ID: 22617366
Is there anyway to do this with T-SQL?  
0
 
LVL 29

Assisted Solution

by:QPR
QPR earned 500 total points
ID: 22618124
open text files and extraxt data?
No. You could put the code into a .bat file and then use SQL to execute the .bat file
0
Free Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

 
LVL 1

Author Comment

by:countyprob
ID: 22647156
This is becoming challenging.  Is there a tool out there that can help me import char based fix flat file data into SQL Server?
0
 
LVL 1

Author Comment

by:countyprob
ID: 22767429
I formatted the data using foxpro and then exported it a csv file.  next I imported the csv file into sql sever using the import wizard
0
 
LVL 1

Author Closing Comment

by:countyprob
ID: 31501856
I had to manipulate data using foxpro, then export to csv and finally import the csv into sql server using the wizard
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how the fundamental information of how to create a table.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question