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 - 15 Nov 2006 04:19 GMT
>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.

Signature
Charles Calvert | Software Design/Development
Celtic Wolf, Inc. | Project Management
http://www.celticwolf.com/ | Technical Writing
(703) 580-0210 | Research
Dave Sexton - 15 Nov 2006 09:15 GMT
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.

Signature
Dave Sexton
> The MS SQL has a column using DEC(11) which is an unsignedInt.
>
[quoted text clipped - 8 lines]
>
> Thanks.
light_wt - 15 Nov 2006 18:18 GMT
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.