how to map datatypes...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • light_wt

    #1

    how to map datatypes...

    The MS SQL has a column using DEC(11) which is an unsignedInt.

    What is the correct way to declare the unsignedInt variable in c# to insert
    this value to MS SQL?

    recall from SQL2k BOL
    Use the int data type to store numbers in the range from -2,147,483,648
    through 2,147,483,647 only (requires 4 bytes of storage per value).

    What I like to do is use the entire range as a positive value.

    Thanks.
  • Charles Calvert

    #2
    Re: how to map datatypes...

    On Tue, 14 Nov 2006 19:25:01 -0800, light_wt
    <lightwt@discus sions.microsoft .comwrote in
    <D0295A78-EB32-46D4-AA65-CF19120F4401@mi crosoft.com>:
    >The MS SQL has a column using DEC(11) which is an unsignedInt.
    >
    >What is the correct way to declare the unsignedInt variable in c# to insert
    >this value to MS SQL?
    2 bytes: UInt16
    4 bytes: UInt32
    8 bytes: UInt64

    Note that these types are not CLS-compliant.
    --
    Charles Calvert | Software Design/Development
    Celtic Wolf, Inc. | Project Management
    http://www.celticwolf.com/ | Technical Writing
    (703) 580-0210 | Research

    Comment

    • Dave Sexton

      #3
      Re: how to map datatypes...

      Hi,

      In Sql Server, "dec" is an alias for the "decimal" data type. Dec(11)
      represents a signed, numeric data type with a precision of 11 and no scale,
      meaning that there can be no digits to the right side of the decimal.

      According to the docs, a precision of 11 requires 9 bytes:

      "decimal and numeric (Transact-SQL)"
      http://msdn2.microsoft.com/en-us/library/ms187746.aspx

      To maximize the capacity of values in managed code and to retain the sign of
      the number, you must use System.Decimal, which is the only primitive structure
      capable of representing all possible values of dec(11), AFAIK.

      --
      Dave Sexton

      "light_wt" <lightwt@discus sions.microsoft .comwrote in message
      news:D0295A78-EB32-46D4-AA65-CF19120F4401@mi crosoft.com...
      The MS SQL has a column using DEC(11) which is an unsignedInt.
      >
      What is the correct way to declare the unsignedInt variable in c# to insert
      this value to MS SQL?
      >
      recall from SQL2k BOL
      Use the int data type to store numbers in the range from -2,147,483,648
      through 2,147,483,647 only (requires 4 bytes of storage per value).
      >
      What I like to do is use the entire range as a positive value.
      >
      Thanks.

      Comment

      • light_wt

        #4
        Re: how to map datatypes...

        Thank you both of you.

        Yes, Dave. I am going to try using system.decimal in c# to
        represent/passing dec(11) in ms sql.


        Comment

        Working...