Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Right Padding Function
Message
 
 
To
12/10/2003 23:28:30
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00837989
Message ID:
00837990
Views:
25
>Hi folks!
>
>is there any example that describe Padding function for string/varchar
>similar to RPAD or LPAD function in Oracle?
>
>TIA

There're no built-in functions like that. It can be done using other functions or there combinations.
-- Right pad 'myfield' to the lenghth 20
SELECT CAST(myfield as char(20))
-- Left pad 'myfield' to the lenghth 20
SELECT REPLICATE(SPACE(1), 20 - DATALENGTH(@myfield)) + @myfield
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform