How do you import fixed width files into SQL Server

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
LVL 1
countyprobSystem AnalystAsked:
Who is Participating?
 
QPRConnect With a Mentor Commented:
http://www.sqlis.com/55.aspx

"Looping over files with the Foreach Loop"
0
 
countyprobSystem AnalystAuthor Commented:
Is there anyway to do this with T-SQL?  
0
 
QPRConnect With a Mentor Commented:
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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
countyprobSystem AnalystAuthor Commented:
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
 
countyprobSystem AnalystAuthor Commented:
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
 
countyprobSystem AnalystAuthor Commented:
I had to manipulate data using foxpro, then export to csv and finally import the csv into sql server using the wizard
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.