DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  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.



Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links