Re: Maintaining Field Length in .txt format
From: Steve Kass (skass_at_drew.edu)
Date: 11/16/04
- Next message: auto: "Auto-Printing with SQL Reporting Services"
- Previous message: Chris Gaze: "SQL - Am I remembering correctly???"
- In reply to: J. Joshi: "Maintaining Field Length in .txt format"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 16 Nov 2004 17:58:02 -0500
How are you exporting the data now? If you export the data with bcp,
and the column types are CHAR, not VARCHAR, they will be padded with
spaces as you want. If the types are VARCHAR, then export a query that
converts them to CHAR types.
As for appending, I don't think there's a way to do it, but you can
create two text files and append them with a shell command, called from
SQL Server or not (exec master..xp_cmdshell 'COPY a.txt/A+b.txt/A
c.txt/A' from SQL Server).
Steve Kass
Drew University
J. Joshi wrote:
>Hello all,
>
>I have run into something very bizzare and something I
>have not come accross before. We have a data feed that
>goes into a legacy mainframe system (not sure which
>platform) every month. Unfortunately or fortunately, we
>are on a SQL Server 2000 environment and I can create
>a .txt file with 7 required fields.
>
>Here's the problem: The ending position of each field is
>very specific. E.g. LastName field starts @ col.19 & ends
>@ Col43 or 25 characters long (CHAR datatype). How do I
>fill in the gaps with a blank space with the Lastname is
>not 25 characters long? And so on for other fields? That
>to in a .txt file format?
>
>Also - is there any way to append data to an existing .txt
>file using SQL? The header information for the feed to be
>sent creats a .txt file. Then I have to feed in the data-
>set in teh same .txt file using another sproc. The header
>field length is completely diff than the data-set field
>length. This is very old school but such is the nature of
>the project!
>Any ideas on this?
>
>Joshi
>
>
- Next message: auto: "Auto-Printing with SQL Reporting Services"
- Previous message: Chris Gaze: "SQL - Am I remembering correctly???"
- In reply to: J. Joshi: "Maintaining Field Length in .txt format"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|