Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Fixed Width File Importing in SQL

Posted on 2008-06-20
1
Medium Priority
?
222 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 375 total points
ID: 21830041
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

926 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