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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Padding in SQL 2000

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 query

TO_CAHR(LPAD(columnname,20,'0'))

vishu
Bangalore

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 Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

vishu.av
Starting Member

26 Posts

Posted - 2007-04-20 : 07:54:00
Thanks Harsh.


vishu
Bangalore
Go to Top of Page

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 Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

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.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-21 : 11:39:50
Yes. Thanks Don for the correction.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

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.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -