Board index » delphi » How to Insert '0' at the Left Most of the field ??

How to Insert '0' at the Left Most of the field ??

Hello,

   I have a question on how to Insert '0' at the left hand side of the
field , just like the PADL function. example : the field called 'SO_no' and
the type is Integer.
If I want the field has a record '0003' and next record is '0004' etc.
How can I insert the '0' at the left most in the MS SQL server ????

Thanks for your help and attention.

Regard,
   dick Wong

 

Re:How to Insert '0' at the Left Most of the field ??


Put '000000000' into the DisplayFormat

Laurent

Quote
dick Wong wrote in message <01bd7899$156e4700$0b31a1ce@dick_Wong>...
>Hello,

>   I have a question on how to Insert '0' at the left hand side of the
>field , just like the PADL function. example : the field called 'SO_no' and
>the type is Integer.
>If I want the field has a record '0003' and next record is '0004' etc.
>How can I insert the '0' at the left most in the MS SQL server ????

>Thanks for your help and attention.

>Regard,
>  {*word*106} Wong

Re:How to Insert '0' at the Left Most of the field ??


Provided that the receiving field is a character datatype, you can do

  FieldByName('your_field').AsString := Format('%4.4d', [your_integer]);

Jim

Quote
dick Wong wrote:
> Hello,

>    I have a question on how to Insert '0' at the left hand side of the
> field , just like the PADL function. example : the field called 'SO_no' and
> the type is Integer.
> If I want the field has a record '0003' and next record is '0004' etc.
> How can I insert the '0' at the left most in the MS SQL server ????

> Thanks for your help and attention.

> Regard,
>    dick Wong

Other Threads