February 8, 2018 at 6:14 pm
hi ,
I I have 2 column, column1 and column2.
I need to concat this 2 column with column1 should have 40 white space after table.
example ,
123234 10
23 12
1234 12
I am using space function but values are not showing right in table.
when I place this column in '' its showing right. but in the table its like below.
cast
(LEFT(column1+space(45),45) aschar(45))+cast(column2aschar(1))
please help
February 8, 2018 at 9:08 pm
If i got your question right, you wish to have a total of 40 spaces in your output after concatenating column1 and column2?
If so this should help you.
create table t(x int,y int);
insert into t values (123234,10);
insert into t values(23,12);
insert into t values(1234,12);
select concat(concat(x,y),replicate(' ',40-datalength(concat(x,y))))
from t;
February 9, 2018 at 8:04 am
coool_sweet - Thursday, February 8, 2018 6:14 PMhi ,
I I have 2 column, column1 and column2.
I need to concat this 2 column with column1 should have 40 white space after table.
example ,
123234 10
23 12
1234 12
I am using space function but values are not showing right in table.
when I place this column in '' its showing right. but in the table its like below.
cast
(LEFT(column1+space(45),45) aschar(45))+cast(column2aschar(1))
please help
The SSMS results panel uses a variable width font as the default. Since spaces are narrower than numbers, they will not line up using the default font. If you want to see how they line up, try outputting to text instead of grid.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply