Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Padding Strings
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Miscellaneous
Thread ID:
01183507
Message ID:
01183514
Views:
18
>How can I pad strings like the VFP PADL() and PADR() command in SQL?
>
>Thanks
If you don't want to use functions:
--- PADL
SELECT RIGHT(REPLICATE(desired char here, length of the padded string)+SomeString, length of the padded strng)
-- i.e in VFP: PADL([MyString],20,[0])
SELECT RIGHT(REPLICATE('0', 20)+'MyString', 20)
-- Result -> '000000000000MyString'


--- PADR
SELECT LEFT(SomeString+REPLICATE(desired char here, length of the padded string), length of the padded strng)
-- i.e in VFP: PADR([MyString],20,[0])
SELECT LEFT('MyString'+REPLICATE('0', 20), 20)
-- Result -> 'MyString000000000000'
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform