Professional Web Applications Themes

Keep Leading Zeros SQL Server 2000 - ASP Database

I'm inserting this 00111 into a one column table in sql server 2000. It keeps changing the value to 111. How can I get it to insert the information keeping the leading zeros? Please let me know. James...

  1. #1

    Default Keep Leading Zeros SQL Server 2000

    I'm inserting this 00111 into a one column table in sql
    server 2000. It keeps changing the value to 111. How can
    I get it to insert the information keeping the leading
    zeros?

    Please let me know.

    James
    James Guest

  2. #2

    Default Re: Keep Leading Zeros SQL Server 2000

    I am guessing the column a numeric one, right? If so, the behaviour is
    correct. If you want to keep the leading zeroes, change the column to
    varchar.

    --
    Manohar Kamath
    Editor, .netWire
    www.dotnetwire.com


    "James" <microsoft.com> wrote in message
    news:309a01c4a246$35657af0$gbl... 


    Manohar Guest

  3. #3

    Default Re: Keep Leading Zeros SQL Server 2000

    Actually it is a char field. I thought that by being a
    char field, it would allow the leading digits to stay,
    wrong.

    James 
    behaviour is 
    the column to 
    message [/ref]
    can 
    >
    >
    >.
    >[/ref]
    James Guest

  4. #4

    Default Re: Keep Leading Zeros SQL Server 2000

    What does "keeps changing" mean? What is "it"? Where are you viewing the
    values and confirming that the leading 0's are being stripped? Are you sure
    it's not your client application that is doing this?

    If these are all numeric values, I believe you should store them in a
    numeric column and applying this formatting at presentation time rather than
    storing useless 0s. One advantage (aside from wasted storage) is that if
    you change from 5 0's to 6 0's, you merely change the presentation code, and
    you don't have to go back and change all the database values.

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "James" <microsoft.com> wrote in message
    news:309a01c4a246$35657af0$gbl... 


    Aaron Guest

  5. #5

    Default Re: Keep Leading Zeros SQL Server 2000

    That's weird... what is the length of the char field? Also, when do you see
    that the leading zeroes are gone? In querying the field, in enterprise
    manager, or somewhere else?

    --
    Manohar Kamath
    Editor, .netWire
    www.dotnetwire.com


    "James" <microsoft.com> wrote in message
    news:0ac101c4a256$222936b0$gbl... 
    > behaviour is 
    > the column to 
    > message [/ref]
    > can 
    > >
    > >
    > >.
    > >[/ref][/ref]


    Manohar Guest

  6. #6

    Default Re: Keep Leading Zeros SQL Server 2000

    If you look in the database directly using a DBMS utility are the leading 0s
    in place?

    Show the code you are using to update, retrieve, and display the data. There
    is probably an explicit or implicit conversion to integer somewhere.

    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    www.ielearning.com


    "James" <microsoft.com> wrote in message
    news:0ac101c4a256$222936b0$gbl... 
    > behaviour is 
    > the column to 
    > message [/ref]
    > can 
    > >
    > >
    > >.
    > >[/ref][/ref]


    Mark Guest

Similar Threads

  1. Leading Zeros not being read from Excel Query
    By cmkelly in forum Coldfusion Database Access
    Replies: 2
    Last Post: October 18th, 08:33 PM
  2. Disappering leading zeros
    By elvis is dead in forum Macromedia ColdFusion
    Replies: 0
    Last Post: May 13th, 11:23 AM
  3. CSV file - Leading Zeros
    By Paul Kraus in forum PERL Beginners
    Replies: 5
    Last Post: December 15th, 10:22 PM
  4. Insert leading zeros
    By Matt Palermo in forum PHP Development
    Replies: 2
    Last Post: July 16th, 12:48 AM
  5. CSV for Excel - Problem with Leading Zeros
    By Luke Zhang [MSFT] in forum ASP.NET General
    Replies: 0
    Last Post: June 26th, 01:34 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139