Solved

How do you import fixed width files into SQL Server

Posted on 2008-09-30
6
331 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
  • 4
  • 2
6 Comments
 
LVL 29

Accepted Solution

by:
QPR earned 500 total points
Comment Utility
http://www.sqlis.com/55.aspx

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

Author Comment

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

Assisted Solution

by:QPR
QPR earned 500 total points
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:countyprob
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now