SQL Server type vs C # type comparison

Source: Internet
Author: User

SQL SERVER type

C # type

Exact numbers

bigint

Integer data (all numbers) from -2^63 (-9223372036854775808) to 2^63-1 (9223372036854775807). The storage size is 8 bytes.

About 90 billion, with less

Int64

Int

Integer data (all numbers) from -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647). The storage size is 4 bytes. The SQL-92 synonymous word for int is integer.

Int32

smallint

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

Int16

tinyint

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

System.Byte

Bit

Integer data of 1 or 0.

Boolean

Decimal

Fixed precision and decimal digit data from -10^38 +1 to 10^38–1.

System.Decimal

Numeric

Functionally equivalent to decimal.

System.Decimal

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.

System.Decimal

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.

System.Decimal

Approximate numbers

Float

Floating-point precision numbers from -1.79e + 308 to 1.79E + 308.

System.Double

Real

Floating-point precision numbers from -3.40e + 38 to 3.40E + 38.

System.Single

Datetime

Date and time data from January 1, 1753 to December 31, 9999, accurate to 3% seconds (or 3.33 milliseconds).

System.DateTime

smalldatetime

Date and time data from January 1, 1900 to June 6, 2079, accurate to minutes.

System.DateTime

String

Char

Fixed-length non-Unicode character data with a maximum length of 8,000 characters.

String

varchar

Variable-length non-Unicode data with a maximum of 8,000 characters.

String

Text

Variable-length non-Unicode data with a maximum length of 2^31-1 (2,147,483,647) characters.

String

Unicode string

NChar

Fixed-length Unicode data with a maximum length of 4,000 characters.

String

nvarchar

Variable-length Unicode data with a maximum length of 4,000 characters. sysname is a system-supplied user-defined data type that is functionally equivalent to nvarchar, which refers to the database object name.

String

ntext

Variable-length Unicode data with a maximum length of 2^30-1 (1,073,741,823) characters.

String

Binary string

Binary

Fixed-length binary data with a maximum length of 8,000 bytes.

System.byte[]

varbinary

Variable-length binary data with a maximum length of 8,000 bytes.

System.byte[]

Image

Variable-length binary data with a maximum length of 2^31-1 (2,147,483,647) bytes.

System.byte[]

Other data types

Timestamp

The unique number of database scopes that are updated each time the row is updated.

System.DateTime

uniqueidentifier

The globally unique identifier (GUID).

System.Guid

Variant

Object

SQL Server type vs C # type comparison

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.