Solved

Define field lengths for MS SQL 2000 DTS bulk export to text file

Posted on 2007-11-28
5
513 Views
Last Modified: 2013-12-18
Hi,

i try to prepare an export of an SQL query into a text file which fields should be of a delimited lenght. The file should be like (the export has 2 fields and if field1 is 10 char and field2 is 8 char):
field1....field2..field1b...field2b. (where points are spaces in the example).

I thought doing this with the SQL 2000 DTS Bulk export bue i don't know where to set the fields length.

Thanks for your help.
 
0
Comment
Question by:jeebee75
5 Comments
 
LVL 31

Expert Comment

by:James Murrell
ID: 20366729
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 20367483
You do not define the lengths when using a delimited format.  That is the whole point of delimited files.

If I am not understanding, than please indicate what is the current output and the desired output.
0
 
LVL 32

Accepted Solution

by:
bhess1 earned 500 total points
ID: 20369608
Fixed-Length fields is what you are looking for.  Use DTS export, choose to export to a text file, choose fixed-field export, choose <none> for the row delimiter, and export away.
0
 

Author Comment

by:jeebee75
ID: 20372179
Thanks for your posts.
Each record of the output file should be 372 char length. There should be no delimiter between the fields but blanks to complete each field length:

Field      Type      Position      Length
a      char      1      5
b      char      6      6
c      char      12      9
d      char      21      50
e      char      71      50
f      char      121      3
g      char      124      50
h      char      174      50
i      char      224      5
j      char      229      10
k      char      239      10
l      char      249      10
m      char      259      50
n      char      309      13
o      char      322      50

Thanks for your help

0
 

Author Comment

by:jeebee75
ID: 20374881
I found the solution. I had to use the "define columns" (and specify each field length) in the transform data task and choose <none> for the row delimiter as bhess1 told me.

Thanks for your help
0

Featured Post

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!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
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.
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
Viewers will learn how the fundamental information of how to create a table.

713 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