Solved

Fixed Width File Importing in SQL

Posted on 2008-06-20
1
215 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
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

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.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

839 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