Solved

Fixed Width File Importing in SQL

Posted on 2008-06-20
1
212 Views
Last Modified: 2013-11-30
I have 8 large text files(approx 4GB each) , all of them are formatted in fixed width - each with the same layout. There are also roughly 400 columns on each file.

I have a layout guide telling me the field names, field start column and and field width.

My question is, is there an easy way to import the files into SQL server 2005, perhaps utilising the layout guide i have, rather than manually specifying column widths for the files in something like the Import wizard in SQL?
0
Comment
Question by:adamcutting
1 Comment
 
LVL 17

Accepted Solution

by:
dbaSQL earned 125 total points
Comment Utility
oh yes.  you should use bulk insert, it is probably one of the fastest means of loading the data to sql, and you can specify the file formats (layout guide) using a format file.  
see here, very good information regarding bulk insert:
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/be3984e1-5ab3-4226-a539-a9f58e1e01e2.htm

also, details regarding the format file you'll need to use to specify datatypes, lengths, order, etc.:
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/b7b97d68-4336-4091-aee4-1941fab568e3.htm

0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

763 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

7 Experts available now in Live!

Get 1:1 Help Now