Solved

How do you import fixed width files into SQL Server

Posted on 2008-09-30
6
333 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
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!

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

816 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

11 Experts available now in Live!

Get 1:1 Help Now