Friday, March 23, 2012

Right justify char column

How do I get the output of a SELECT statement to right justify a char (datat
ype) column?
Thanks,
JeffCan't you do that at the application / presentation layer?
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"Jeff C." <anonymous@.discussions.microsoft.com> wrote in message
news:E7E61AC1-A8B4-4E43-B502-0B794F564A65@.microsoft.com...
> How do I get the output of a SELECT statement to right justify a char
(datatype) column?
> Thanks,
> Jeff|||Jeff C. wrote:

> How do I get the output of a SELECT statement to right justify a char
> (datatype) column?
Taken from
http://groups.google.pl/groups?hl=p...&rnu
m=3
Declare @.InVal Char(38)
Declare @.ReplaceChar Char(1)
Select @.InVal = 'This is a test'
Select @.ReplaceChar ='x'
Select Replicate(@.ReplaceChar, 38 - Len(@.InVal)) + @.InVal
sincerely,
--
Sebastian K. Zaklada
Skilled Software
http://www.skilledsoftware.com
This posting is provided "AS IS" with no warranties, and confers no rights.

No comments:

Post a Comment