Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2006
    Posts
    13

    Unanswered: Using Numeric Data Types

    Hi All,

    I'm using ASE 12.0 and i've a query regarding columns with numeric data type.

    How the length is calculated from the precision and scale supplied while creating the table. eg: Numeric(12,3). How the length for the column is calculated.

    Any help will be appreciated.

    Thanks,
    Sumesh

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    The storage size for a numeric or decimal column depends on its precision
    e.g.
    select "prec"=colid, length=ceiling(colid/log10(256))+1
    from syscolumns
    where id=16 and colid<39
    order by colid

  3. #3
    Join Date
    Nov 2006
    Posts
    13
    Thanks for the reply.

    Can u pls explain what is actually meant by length of a column when we specify precision and scale as Numeric(12,3).

    Thanks a lot
    Sumesh

  4. #4
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Length is the storage size
    i.e.
    It takes ceiling(12/log10(256))+1=6 bytes to store a numeric(12,3)
    Last edited by pdreyer; 01-23-07 at 08:42.

  5. #5
    Join Date
    Nov 2006
    Posts
    13
    Thanks a lot

  6. #6
    Join Date
    Nov 2006
    Posts
    13
    Quote Originally Posted by pdreyer
    Length is the storage size
    i.e.
    It takes ceiling(12/log10(256))+1=6 bytes to store a numeric(12,3)
    .

    But you have mentioned 'ceiling(colid/log10(256))+1'.
    Please confirm how can you say that here column id =12.

  7. #7
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    In the 1st example I only used syscolumns as if it is a temp table with colid as a sequential sequence number rather then having to generate my own temp table with possible values for precision.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •