Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Right Padding Function
Message
 
 
À
12/10/2003 23:28:30
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00837989
Message ID:
00837990
Vues:
23
>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--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform