| Author |
Topic |
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2008-05-06 : 08:46:21
|
| After the amount i need some space can i know how to do this:Sample data which i tried for string is:declare @str varchar(10)set @str='testing'select space(10) +@str as 'Display'--How this can be done for int data type and the space should come at right-hand sidedeclare @i intset @i=1000select @i+space(10) as 'disp' |
|
|
Vadivu
Starting Member
31 Posts |
Posted - 2008-05-06 : 08:53:51
|
| y do u want to do this in sql? |
 |
|
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2008-05-06 : 08:56:30
|
since we are using our own front end.it is not feasablequote: Originally posted by sent_sara After the amount i need some space can i know how to do this:Sample data which i tried for string is:declare @str varchar(10)set @str='testing'select space(10) +@str as 'Display'--How this can be done for int data type and the space should come at right-hand sidedeclare @i intset @i=1000select @i+space(10) as 'disp'
|
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-05-06 : 09:02:44
|
| [code]select cast(@i as varchar(5)) + space(10) as 'disp'[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
Vadivu
Starting Member
31 Posts |
Posted - 2008-05-06 : 09:07:55
|
| this is not working i guess... space function is adding space in left side and not in right side... or am i missing something? |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-05-06 : 09:12:47
|
quote: Originally posted by Vadivu this is not working i guess... space function is adding space in left side and not in right side... or am i missing something?
Have you tried running it?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2008-05-06 : 09:22:50
|
i tried it .space is not working at rightsidequote: Originally posted by harsh_athalye
select cast(@i as varchar(5)) + space(10) as 'disp' Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
|
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-05-06 : 09:26:44
|
| I am not sure what you need then. Do you want space to be added to the left of number or to the right of it?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2008-05-06 : 09:29:29
|
right of it.quote: Originally posted by harsh_athalye I am not sure what you need then. Do you want space to be added to the left of number or to the right of it?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
|
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-05-06 : 09:34:03
|
What's wrong with the solution I posted then?declare @i intset @i = 1000select cast(@i as varchar(5)) + space(10) as 'disp' Output:disp--------------1000 (1 row(s) affected) Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2008-05-06 : 09:41:00
|
space is not coming at right sidedisp----1000quote: Originally posted by harsh_athalye What's wrong with the solution I posted then?declare @i intset @i = 1000select cast(@i as varchar(5)) + space(10) as 'disp' Output:disp--------------1000 (1 row(s) affected) Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
|
 |
|
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2008-05-06 : 09:42:40
|
i copied your query and executed quote: Originally posted by sent_sara space is not coming at right sidedisp----1000quote: Originally posted by harsh_athalye What's wrong with the solution I posted then?declare @i intset @i = 1000select cast(@i as varchar(5)) + space(10) as 'disp' Output:disp--------------1000 (1 row(s) affected) Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
|
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-05-08 : 04:17:26
|
| declare @i intset @i = 1000select cast(@i as varchar(5)) + space(10)+'test' as 'disp'MadhivananFailing to plan is Planning to fail |
 |
|
|
|