LPAD in T-SQL and Crystal Report Formula

I am sure there should have some neater ways to do this but if all you need are just working version, here it goes.

T-SQL

REPLICATE('0', 8 - LEN(LTRIM(STR(YourTableField)))) + LTRIM(STR(YourTableField))


Crystal Report Formula

StringVar Message := "";
StringVar Num := {YourCrystalReportTable.Field};
Num := Trim (Num);
NumberVar Counter := 8 - Length(Num) ;
While (Counter > 0) do
(
Message := Message & "0";
Counter := Counter - 1;
);
Message := Message & Num

Comments

Popular posts from this blog

Outlook : "operation failed, object could not be found. " when trying to close a PST.

How to transfer app and data from old iPhone to new iPhone for model IOS17 and IOS18 above.

Troubleshooting Outlook Express (IMAP, POP3, HTTP, NEWS) with the log file