C# Equivalent of SQL Server DataTypes

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

C# Equivalent of SQL Server DataTypes

Message par ForumBot »

C# Equivalent of SQL Server DataTypes
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: C# Equivalent of SQL Server DataTypes

Message par ForumBot »

This is for [SQL Server 2005](http://msdn.microsoft.com/en-us/library/ms131092(SQL.90).aspx). There are updated versions of the table for [SQL Server 2008](http://msdn.microsoft.com/en-us/library/ms131092%28v=sql.100%29.aspx), [SQL Server 2008 R2](http://msdn.microsoft.com/en-us/library/ms131092%28v=sql.105%29.aspx), [SQL Server 2012](http://msdn.microsoft.com/en-us/library/ms131092%28v=sql.110%29.aspx) and [SQL Server 2014](http://msdn.microsoft.com/en-us/library/ms131092(v=sql.120).aspx).

SQL Server Data Types and Their .NET Framework Equivalents

The following table lists Microsoft SQL Server data types, their equivalents in the common language runtime (CLR) for SQL Server in the **System.Data.SqlTypes** namespace, and their native CLR equivalents in the Microsoft .NET Framework.

SQL Server data type
CLR data type (SQL Server)
CLR data type (.NET Framework)

varbinary
SqlBytes, SqlBinary
Byte[]

binary
SqlBytes, SqlBinary
Byte[]

varbinary(1), binary(1)
SqlBytes, SqlBinary
byte, Byte[]

image
None
None

varchar
None
None

char
None
None

nvarchar(1), nchar(1)
SqlChars, SqlString
Char, String, Char[]

nvarchar
SqlChars, SqlString
String, Char[]

nchar
SqlChars, SqlString
String, Char[]

text
None
None

ntext
None
None

uniqueidentifier
SqlGuid
Guid

rowversion
None
Byte[]

bit
SqlBoolean
Boolean

tinyint
SqlByte
Byte

smallint
SqlInt16
Int16

int
SqlInt32
Int32

bigint
SqlInt64
Int64

smallmoney
SqlMoney
Decimal

money
SqlMoney
Decimal

numeric
SqlDecimal
Decimal

decimal
SqlDecimal
Decimal

real
SqlSingle
Single

float
SqlDouble
Double

smalldatetime
SqlDateTime
DateTime

datetime
SqlDateTime
DateTime

sql_variant
None
Object

User-defined type(UDT)
None
user-defined type

table
None
None

cursor
None
None

timestamp
None
None

xml
SqlXml
None
Répondre

Revenir à « .NET & C# »