| Author |
Topic |
|
dhani
Posting Yak Master
132 Posts |
Posted - 2009-10-20 : 11:53:34
|
| select eName,Age from emplEname Age------- ----Jhones 35PATRICK 21MathewJunior 29Dan 41when i use below queryselect eName || ' ' || Age from empl Jhones 35PATRICK 21MathewJunior 29Dan 41is there any way that i can get as belowJhones 35PATRICK 21MathewJunior 29Dan 41Please Note: here in the above output the important thing is what ever the string length it has to be aligned as max length string + 1 empty character then ageis it possibleplease help me sirThanks in adavncedhani |
|
|
dhani
Posting Yak Master
132 Posts |
Posted - 2009-10-20 : 12:02:58
|
| Please Any ideas...... |
 |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2009-10-20 : 12:14:11
|
| as below looks exactly as above...can you clarify please...so that we can help<><><><><><><><><><><><><><><><><><><><><><><><><>If you don't have the passion to help people, you have no passion |
 |
|
|
dhani
Posting Yak Master
132 Posts |
Posted - 2009-10-20 : 12:18:49
|
| i am very sorry for confusing all of you,let me explain you total....,,create table emplo (eName varchar(20),age int);insert into emplo values ('AAA',78);insert into emplo values ('BBBBBB',45);insert into emplo values ('C',99);insert into emplo values ('DDDDDDDDD',12);insert into emplo values ('EEEEE',56);insert into emplo values ('FFFF',60);insert into emplo values ('GGGGGGGGGGGGGGG',50);insert into emplo values ('HH',14);when i execute queryselect sname + cast(age as varchar) from emplothe result came in a zig zag position (when age value starts after ename because ename is having different length if values ) here what i am trying is start age at a particular (i through max length + 1 space) positionfor ex AAA is 3 character length string here in this table max length is 15 value GGGG\s so AAA then add (15 - 3) 12 spaces then add age value so next BBBBBB has 6 characters in length so just add 9 spaces then display age after that so finally i will get a eName and age at a nice location (not in a zig zag format)hope this helps a littleif not let me know i will give some more examplesthanks to you, please get out this problemdhani |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-10-20 : 12:59:01
|
| seems like select str(sname + cast(age as varchar),15) from emplo |
 |
|
|
dhani
Posting Yak Master
132 Posts |
Posted - 2009-10-20 : 13:20:57
|
Hello Visakh, Thanks for your Help,but while i am trying to execute the query i am getting below error, i am using sql server 2005Msg 8114, Level 16, State 5, Line 1Error converting data type varchar to float.quote: Originally posted by visakh16 seems like select str(sname + cast(age as varchar),15) from emplo
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-10-20 : 13:42:17
|
| ah...that was a varchar field. then use thisselect sname + str(age,15- len(sname)) from emplo |
 |
|
|
dhani
Posting Yak Master
132 Posts |
Posted - 2009-10-20 : 14:15:20
|
| Thanks Visakh,Half of the waywhen i select result to text option in (Sql Server Management Studeio --> Query menu--> Results to --> Result to Text) is working as i expected,but when i see results in (Sql Server Management Studeio --> Query menu--> Results to --> Result to Grid) is not workingis there any way (the reason is i am using this in one reporting tool which is Business Objects but backend is Sql server, so i have to place two values in one cell which is in a nice way unlike zig zag wayplease there is nothing that i can set @ Business Objects Level, only i have to do @ sql server levelThansk inadvancedhani |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-10-20 : 14:19:58
|
| select sname + replicate(' ',15-len(sname)) + cast(age as varchar) from emplo |
 |
|
|
dhani
Posting Yak Master
132 Posts |
Posted - 2009-10-20 : 15:12:37
|
| Really Thanks to you Visakh,i chaged the font type to LUCIDA it is owrking fine with you last postand also Thanks to all whome ever contributed their ideas in this postThanks to alll |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-10-20 : 15:16:15
|
| welcome |
 |
|
|
|