Solved

Fixed Width File Importing in SQL

Posted on 2008-06-20
1
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: 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

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.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

630 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