October 28, 2005 at 1:30 pm
After my last post (MUCK tables)... please be gentle. (Yes, I owe her dinner!)
I am trying to create a fixed length field in an output file using a query. So I am CAST(<column name> as CHAR(10)). Well, I would like the data to be right justified. The only solution that I can come up with is using CASE WHEN and measure the column with LEN and then concatenate the required number of spaces in front of the data. Anyone know of a better method?
Thanks
Steve
October 28, 2005 at 1:57 pm
Sorry but this is a presentation issue and it should be taken care of application side.
October 28, 2005 at 3:11 pm
Well it really is not a presentation issue since the data is being exported into a file and the client wants it right justified. - But I get your point
October 28, 2005 at 3:12 pm
Alright... can't go against what they want .
October 28, 2005 at 3:47 pm
Clients are gods - $$ flow from them... but life would be easier... I guess I won't go there.
October 30, 2005 at 8:07 am
Just adding my two cents...
Use STR(n,l,d) for numerics on this...
n = number to convert
l = final length of all characters (defaults to 10)
d = number of decimal places (defaults to 0)
If they need to be zero filled...
REPLACE(STR(n,l,d),' ','0')
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply