C#等效的SQL Server数据类型 [英] C# Equivalent of SQL Server DataTypes
问题描述
对于下面的SQL Server数据类型,这将是在C#中的相应数据类型?
For the following SQL Server datatypes, what would be the corresponding datatype in C#?
精确Numerics的
bigint
numeric
bit
smallint
decimal
smallmoney
int
tinyint
money
近似Numerics的
float
real
日期和时间
date
datetimeoffset
datetime2
smalldatetime
datetime
time
字符串
char
varchar
text
的Uni code字符串
nchar
nvarchar
ntext
二进制字符串
binary
varbinary
image
其他数据类型
cursor
timestamp
hierarchyid
uniqueidentifier
sql_variant
xml
table
(来源: MSDN )
推荐答案
它可以帮助得到这个答案可搜索拥有这一切在出任的乔治·斯托克想要的。
It could help to get this answer searchable to have it all in the post as George Stocker wanted.
这是 SQL Server 2005的。有表的 SQL Server 2008的的更新版本, SQL Server 2008 R2的,的SQL Server 2012的和的的SQL Server 2014年。
This is for SQL Server 2005. There are updated versions of the table for SQL Server 2008, SQL Server 2008 R2, SQL Server 2012 and SQL Server 2014.
下表列出了Microsoft SQL Server数据类型,它们在公共语言运行库(CLR)对于SQL Server在 System.Data.SqlTypes 命名空间当量,其本地CLR等同于微软.NET框架。
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
这篇关于C#等效的SQL Server数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!