locked
which datatype should i use to store.... RRS feed

  • Question

  • I'm reding some data from win32_ComputerSystem

    like

    TotalPhsicalMemory=queryObj["TotalPhysicalMemory"];-> returns uint64

    PartOfDomain = queryObj["PartOfDomain"];->returns bool

        PCSystemType = queryObj["PCSystemType"];-> returns uint16

    to store this data what datatype should i use?

    Friday, February 24, 2012 3:02 PM

Answers

  • bool --> bit
    unit16 --> decimal(5) numeric(5) or integer*
    unit64 --> numeric(20) or decimal(20)

    * While integer will work for unit16, it is not ideal
       -- but then again, neither domain for the unitxx datatype matches exactly with an SQL datatype

    unit16 almost translates to SMALLINT; however unit16 can accept positive values that are approximately twice the magnitude of the SMALLINT datatype.

    select 
      convert(bigint, 0x7fffffffffffffff) as bigint_Limit,
      convert(smallint, 0x7fff) as smallint_Limit
    /* -------- Output: --------
    bigint_Limit         smallint_Limit
    -------------------- --------------
    9223372036854775807  32767
    */

    Friday, February 24, 2012 3:15 PM

All replies