Solved

How do you import fixed width files into SQL Server

Posted on 2008-09-30
6
332 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
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

932 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

12 Experts available now in Live!

Get 1:1 Help Now