C#等效的SQL Server数据类型

C#等效的SQL Server数据类型

对于以下SQL Server数据类型,C#中相应的数据类型是什么?

精确的数字

bigint
numeric
bit
smallintdecimalsmallmoneyinttinyint
money

近似数字

floatreal

日期和时间

date
datetimeoffset
datetime2
smalldatetime
datetime
time

字符串

charvarchar
text

Unicode字符串

nchar
nvarchar
ntext

二进制字符串

binary
varbinary
image

其他数据类型

cursor
timestamp
hierarchyid
uniqueidentifier
sql_variant
xml
table

(来源:MSDN


RISEBY
浏览 433回答 3
3回答

大话西游666

这适用于SQL Server 2005。SQL Server 2008,SQL Server 2008 R2,SQL Server 2012和SQL Server 2014的表的更新版本。SQL Server数据类型及其.NET Framework等价物下表列出了Microsoft SQL Server数据类型,它们在System.Data.SqlTypes命名空间中SQL Server的公共语言运行时(CLR)中的等效项,以及Microsoft .NET Framework中它们的本机CLR等效项。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                          Nonevarchar                       None                          Nonechar                          None                          Nonenvarchar(1), nchar(1)         SqlChars, SqlString           Char, String, Char[]     nvarchar                      SqlChars, SqlString           String, Char[] nchar                         SqlChars, SqlString           String, Char[] text                          None                          Nonentext                         None                          Noneuniqueidentifier              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                          Nonetimestamp                     None                          None xml                           SqlXml                        None
打开App,查看更多内容
随时随地看视频慕课网APP