dbTalk Databases Forums  

Right Justify amounts

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Right Justify amounts in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jim Covington
 
Posts: n/a

Default Right Justify amounts - 04-08-2004 , 04:22 PM






I am using DTS in SQL 2000 to download data to a text file. (Fixed Width
Columns)

All works well but the numbers are all left justified.

How to I right justify in Transformations?

Jim



Reply With Quote
  #2  
Old   
Sue Hoegemeier
 
Posts: n/a

Default Re: Right Justify amounts - 04-08-2004 , 07:27 PM






Jim,
Basically, you don't. Justification of data is a controlled
through whatever client tool you use to view the data. You
would control display behavior through a client app, not on
a transformation.

-Sue

On Thu, 8 Apr 2004 16:22:28 -0500, "Jim Covington"
<jim (AT) firstbankms (DOT) com> wrote:

Quote:
I am using DTS in SQL 2000 to download data to a text file. (Fixed Width
Columns)

All works well but the numbers are all left justified.

How to I right justify in Transformations?

Jim



Reply With Quote
  #3  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Right Justify amounts - 04-09-2004 , 02:26 AM



In addition to Sue's comments I would add that because you are using FW text
files then maybe you can pad the strings as they go to text file so

Source val = 1234
Destination val needs to be 1234

I would convert to string and then pad the length at the start with " "
until I reached the length of my column



--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"Sue Hoegemeier" <Sue_H (AT) nomail (DOT) please> wrote

Quote:
Jim,
Basically, you don't. Justification of data is a controlled
through whatever client tool you use to view the data. You
would control display behavior through a client app, not on
a transformation.

-Sue

On Thu, 8 Apr 2004 16:22:28 -0500, "Jim Covington"
jim (AT) firstbankms (DOT) com> wrote:

I am using DTS in SQL 2000 to download data to a text file. (Fixed Width
Columns)

All works well but the numbers are all left justified.

How to I right justify in Transformations?

Jim





Reply With Quote
  #4  
Old   
DTJ
 
Posts: n/a

Default Re: Right Justify amounts - 04-09-2004 , 05:16 PM



On Thu, 08 Apr 2004 18:27:29 -0600, Sue Hoegemeier
<Sue_H (AT) nomail (DOT) please> wrote:


Quote:
On Thu, 8 Apr 2004 16:22:28 -0500, "Jim Covington"
jim (AT) firstbankms (DOT) com> wrote:

I am using DTS in SQL 2000 to download data to a text file. (Fixed Width
Columns)

All works well but the numbers are all left justified.

How to I right justify in Transformations?

Jim

top posting corrected

Quote:
Jim,
Basically, you don't. Justification of data is a controlled
through whatever client tool you use to view the data. You
would control display behavior through a client app, not on
a transformation.

-Sue
This is not a correct statement, in that you are dictating design.
Yes, you can do it your way, but you can also do it his way. It
sounds like your assumption is that the text file is for human
consumption, and that you are ignoring other possibilities. This is
not a good thing to do.

I have a vendor that requires a flat file with specific justification
of various data elements. The DTS package that I created does it for
me.

I don't recall the exact method I used. However, the likely answer is
that I used CONVERT or CAST. If I remember, I will take a look and
post again.


Reply With Quote
  #5  
Old   
DTJ
 
Posts: n/a

Default Re: Right Justify amounts - 04-09-2004 , 05:17 PM



On Fri, 9 Apr 2004 08:26:16 +0100, "Allan Mitchell"
<allan (AT) no-spam (DOT) sqldts.com> wrote:

Quote:
In addition to Sue's comments I would add that because you are using FW text
files then maybe you can pad the strings as they go to text file so

Source val = 1234
Destination val needs to be 1234

I would convert to string and then pad the length at the start with " "
until I reached the length of my column
In anticipation of the next question, you can determine the length of
the current string, and then subtract that from the field length to
determine how many spaces to pad...


Reply With Quote
  #6  
Old   
Sue Hoegemeier
 
Posts: n/a

Default Re: Right Justify amounts - 04-10-2004 , 05:33 PM



Yeah...good catch Allan, I read it backwards (as in text
file going in).
Jim - you could also do this in T-SQL if you are using a
query to export to your text file which can sometimes end up
giving you better performance, depending on your package,
your needs. If you needed these padded with spaces, an
example for a width of 10 would be something like:
replicate(' ' , 10 - Len(cast(YourAmt as varchar))) +
cast(YourAmt as varchar)
A lot of the payroll, 401K trust companies, financial
systems I've exported text files for require the numeric
data be padded with 0 so you'd just replicate '0' instead.

-Sue

On Fri, 9 Apr 2004 08:26:16 +0100, "Allan Mitchell"
<allan (AT) no-spam (DOT) sqldts.com> wrote:

Quote:
In addition to Sue's comments I would add that because you are using FW text
files then maybe you can pad the strings as they go to text file so

Source val = 1234
Destination val needs to be 1234

I would convert to string and then pad the length at the start with " "
until I reached the length of my column



--


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.