Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
vishu.av
Starting Member
26 Posts |
Posted - 2007-04-20 : 07:14:10
|
| Hi All,Is there equivalent of LPAD in SQL 2000 similar to that in Oracle?I am trying to work out for below piece of queryTO_CAHR(LPAD(columnname,20,'0'))vishuBangalore |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-20 : 07:17:10
|
| [code]Left(replicate('0',20) + columnname, 20)[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
vishu.av
Starting Member
26 Posts |
Posted - 2007-04-20 : 07:54:00
|
| Thanks Harsh.vishuBangalore |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-20 : 07:59:50
|
Alternately you can do it this way:select replace(str(columnname, 20), ' ', '0') Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-04-20 : 13:02:19
|
| Don't you mean RIGHT(replicate('0',20) + columnname, 20)[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-21 : 11:39:50
|
| Yes. Thanks Don for the correction.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-04-23 : 09:04:23
|
I beat the PesoBOT to the punch! I win![Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|
|
|