SQL Server type corresponds to C # type

Source: Internet
Author: User
Tags numeric value

SQL Server 2000

C#

Codesmith

Data type

Range of values

Data type

Range of values

Null value instead of value

Data type

bigint

-2^63 (-9,223,372,036,854,775,807) to 2^63-1 (9,223,372,036,854,775,807)

Int64

-9,223,372,036,854,775,808; hexadecimal 0x8000000000000000 to 9,223,372,036,854,775,807; hexadecimal 0x7fffffffffffffff

Int64.minvalue

Int64

Binary

A fixed-length n -byte binary data. N must be from 1 to 8,000. The storage space size is n+ 4 bytes.

Byte[]

Null

Binary

Bit

True,false

Enum

0,1,-1 (instead of using an enumeration variable)

public enum Bitnull

{

False,

True,

Null =-1

};

-1

Boolean

Char

A fixed-length, non-Unicode character data with a length of n bytes. n must be a numeric value between 1 and 8,000. The storage size is n bytes.

String

Null

Ansistringfixedlength

Datetime

Store dates from January 1, 1753 to December 31, 9999 (each value requires 8 bytes of storage space)

Datetime

January 1, 01 00:00:00.0000000 to December 31, 9999 23:59:59.9999999

1753-01-01 0:00:00

Datetime

Decimal

From-10^38 +1 to 10^38-1

Decimal

-79,228,162,514,264,337,593,543,950,335 to 79,228,162,514,264,337,593,543,950,335

Decimal.minvalue

Decimal

Float

Floating-point digital data from 1.79E + 308 to 1.79E + 308

Double

-1.79769313486232e308 to +1.79769313486232e308

Double.minvalue

Double

Image

Variable-length binary data is between 0 and 231-1 (2,147,483,647) bytes.

Byte[]

Null

Binary

Int

Integer data from -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647) (all numbers)

Int

2,147,483,648 to 2,147,483,647

-2147483648

Int32

Money

The currency data value is between -2^63 ( -922,337,203,685,477.5808) and 2^63-1 (+922,337,203,685,477.5807), which is accurate to 10 per thousand of the currency unit. The storage size is 8 bytes.

Single

-3.402823e38 to +3.402823e38

Single.minvalue

Currency

NChar

A maximum of 4,000 Unicode characters

String

Null

Stringfixedlength

ntext

The maximum length of a variable-length Unicode data is 230-1 (1,073,741,823) characters. The storage size is twice times the number of characters entered (in bytes).

String

Null

String

Numeric

When using maximum precision, valid values are from-10^38 +1 to 10^38–1

Decimal

-79,228,162,514,264,337,593,543,950,335 to 79,228,162,514,264,337,593,543,950,335

Decimal.minvalue

Decimal

nvarchar

A variable-length Unicode character data that contains n characters. The value of n must be between 1 and 4,000.

String

Null

String

Real

Floating-point numeric data from 3.40E + 38 to 3.40E + 38. The storage size is 4 bytes.

Single

-3.402823e38 to +3.402823e38

Single.minvalue

Single

smalldatetime

The date from January 1, 1900 to June 6, 2079 (each value requires 4 bytes of storage space).

Datetime

January 1, 01 00:00:00.0000000 to December 31, 9999 23:59:59.9999999

1900-01-01 0:00:00

Datetime

smallint

Integer data from -2^15 (-32,768) to 2^15-1 (32,767). The storage size is 2 bytes.

Int16

-32768 to 32767

Int16.minvalue

Int16

SmallMoney

The currency data value is between -214,748.3648 and +214.748,3647 and is accurate to 10 per thousand of the currency unit. The storage size is 4 bytes.

Single

-3.402823e38 to +3.402823e38

Single.minvalue

Currency

sql_variant

Large data types are not supported in SQL Server 2000 text, ntext, image, timestamp, other types are supported

Object

Null

Object

Text

The maximum length of a variable-length non-Unicode data in a server code page is 231-1 (2,147,483,647) characters. When the server code page uses double-byte characters, the storage is still 2,147,483,647 bytes. The storage size may be less than 2,147,483,647 bytes (depending on the string).

String

Null

Ansistring

Timestamp

timestamp This data type shows the automatically generated binary number, ensuring that these numbers are unique in the database. timestamp is generally used as a mechanism for adding a version stamp to a table row. The storage size is 8 bytes.

Byte[]

Null

Binary

tinyint

Integer data from 0 to 255. The storage size is 1 bytes.

Byte

0 to 255

Byte.minvalue

Byte

uniqueidentifier

Stores a 16-byte binary value that uses the same value as the globally unique identifier (GUID). A GUID is a unique binary number, and no two computers in the world will generate duplicate GUID values. GUIDs are primarily used to assign identifiers that must be unique in a network with multiple nodes and multiple computers.

Guid

Guid.Empty

Guid

varbinary

n bytes Variable-length binary data. n must be from 1 to 8,000. The size of the storage space is the actual input data length + 4 bytes Instead of n bytes. The data entered may be 0 bytes in length.

Byte[]

Null

Binary

varchar

Variable-length, non-Unicode character data with a length of n bytes. n must be a numeric value between 1 and 8,000. Storage size is the actual length of bytes of input data, not n bytes. The input data character length can be zero.

String

Null

Ansistring

Reference: http://www.cnblogs.com/suizhikuo/archive/2011/11/26/2264294.html

SQL Server type corresponds to C # type

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.