Formatting a String


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Formatting a String

  1. #1
    Jim Milam Guest

    Formatting a String


    I am trying to remove the leading zeros on a string ex.(003456, 045672) in
    a stored procedure. At this point i am not sure exactly how to go about doing
    this. Does anyone have any suggestions.

  2. #2
    Michael Tzoanos Guest

    Re: Formatting a String


    Hi Jim,

    You could do it using a loop and the string functions CHAR, LEN and SUBSTRING
    but you would need a cursor and the performance would be bad.

    I am not sure how you would do it in a regular SELECT statement.

    HTH,

    Michael Tzoanos

    "Jim Milam" <jim_milam@questnetx.org> wrote:
    >
    >I am trying to remove the leading zeros on a string ex.(003456, 045672)

    in
    >a stored procedure. At this point i am not sure exactly how to go about

    doing
    >this. Does anyone have any suggestions.



  3. #3
    Michael Tzoanos Guest

    Re: Formatting a String


    Jim,

    I meant CHARINDEX, not CHAR for the string function.


    "Michael Tzoanos" <mtzoanos@hotmail.com> wrote:
    >
    >Hi Jim,
    >
    >You could do it using a loop and the string functions CHAR, LEN and SUBSTRING
    >but you would need a cursor and the performance would be bad.
    >
    >I am not sure how you would do it in a regular SELECT statement.
    >
    >HTH,
    >
    >Michael Tzoanos
    >
    >"Jim Milam" <jim_milam@questnetx.org> wrote:
    >>
    >>I am trying to remove the leading zeros on a string ex.(003456, 045672)

    >in
    >>a stored procedure. At this point i am not sure exactly how to go about

    >doing
    >>this. Does anyone have any suggestions.

    >



  4. #4
    Max Guest

    Re: Formatting a String


    Depending upon the number, you may be able to cast it to an integer and then
    back to a string.

    That would remove leading zeroes. However, if the string would contain a
    number too large to be considered an integer, it wouldn't work.
    "Jim Milam" <jim_milam@questnetx.org> wrote:
    >
    >I am trying to remove the leading zeros on a string ex.(003456, 045672)

    in
    >a stored procedure. At this point i am not sure exactly how to go about

    doing
    >this. Does anyone have any suggestions.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center