惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

AI
AI
GbyAI
GbyAI
Blog — PlanetScale
Blog — PlanetScale
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
L
LangChain Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
U
Unit 42
aimingoo的专栏
aimingoo的专栏
N
Netflix TechBlog - Medium
H
Hackread – Cybersecurity News, Data Breaches, AI and More
A
About on SuperTechFans
B
Blog
I
InfoQ
T
The Exploit Database - CXSecurity.com
H
Heimdal Security Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
L
LINUX DO - 最新话题
Google Online Security Blog
Google Online Security Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Help Net Security
Help Net Security
Stack Overflow Blog
Stack Overflow Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Threat Research - Cisco Blogs
量子位
P
Privacy & Cybersecurity Law Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
SecWiki News
SecWiki News
S
Security @ Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
博客园_首页
The Last Watchdog
The Last Watchdog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
有赞技术团队
有赞技术团队
NISL@THU
NISL@THU
WordPress大学
WordPress大学
K
Kaspersky official blog
D
DataBreaches.Net
Hugging Face - Blog
Hugging Face - Blog
Vercel News
Vercel News
雷峰网
雷峰网
Webroot Blog
Webroot Blog
B
Blog RSS Feed
W
WeLiveSecurity
Scott Helme
Scott Helme
A
Arctic Wolf
阮一峰的网络日志
阮一峰的网络日志
G
Google Developers Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - 笑清风

IDEA 2025.2 Maven 在windows下编译打包中文乱码解决方案 milvus相关概念 milvus介绍 Mockito之doThrow 关于行为面试法——STAR JVM 内存分析工具 MAT 的深度讲解与实践——入门篇《转》 linux top 中的time+ notepad++删除包含指定字符串的行(正则) JVM指令码表 Hadoop家族成员概述 轻松把玩HttpClient之封装HttpClient工具类 Base64 SOAP1.1&SOAP1.2 画图解释SQL联合语句 Elasticsearch相关资源 SQL Server类型的对应关系 Rethrowing exceptions and preserving the full call stack trace The CLR's Thread Pool .Net下获取程序路径的方法
SQL Server 数据类型映射
笑清风 · 2013-10-15 · via 博客园 - 笑清风

SQL Server 和 .NET Framework 基于不同的类型系统。 例如,.NET Framework Decimal 结构的最大小数位数为 28,而 SQL Server 的 decimal 和 numeric 数据类型的最大小数位数为 38。 为了在读取和写入数据时维护数据的完整性,SqlDataReader 将公开用于返回 System.Data.SqlTypes 的对象的 SQL Server 特定的类型化访问器方法以及用于返回 .NET Framework 类型的访问器方法。 SQL Server 类型和 .NET Framework 类型也可通过 DbType 和 SqlDbType 类中的枚举表示,当您指定 SqlParameter 数据类型时可以使用这些枚举。

下表显示推断的 .NET Framework 类型、DbType 和 SqlDbType 枚举以及 SqlDataReader 的访问器方法。

SQL Server 数据库引擎类型

.NET Framework 类型

SqlDbType 枚举

SqlDataReader SqlTypes 类型化访问器

DbType 枚举

SqlDataReader DbType 类型化访问器

bigint

Int64

BigInt

GetSqlInt64

Int64

GetInt64

binary

Byte[]

VarBinary

GetSqlBinary

Binary

GetBytes

bit

Boolean

Bit

GetSqlBoolean

Boolean

GetBoolean

char

String

Char[]

Char

GetSqlString

AnsiStringFixedLength,

String

GetString

GetChars

date

(SQL Server 2008 及以上版本)

DateTime

Date

GetSqlDateTime

Date

GetDateTime

datetime

DateTime

DateTime

GetSqlDateTime

DateTime

GetDateTime

datetime2

(SQL Server 2008 及以上版本)

DateTime

DateTime2

DateTime2

GetDateTime

datetimeoffset

(SQL Server 2008 及以上版本)

DateTimeOffset

DateTimeOffset

DateTimeOffset

GetDateTimeOffset

decimal

Decimal

Decimal

GetSqlDecimal

Decimal

GetDecimal

FILESTREAM 属性 (varbinary(max))

Byte[]

VarBinary

GetSqlBytes

Binary

GetBytes

float

Double

Float

GetSqlDouble

Double

GetDouble

image

Byte[]

Binary

GetSqlBinary

Binary

GetBytes

int

Int32

Int

GetSqlInt32

Int32

GetInt32

money

Decimal

Money

GetSqlMoney

Decimal

GetDecimal

nchar

String

Char[]

NChar

GetSqlString

StringFixedLength

GetString

GetChars

ntext

String

Char[]

NText

GetSqlString

String

GetString

GetChars

numeric

Decimal

Decimal

GetSqlDecimal

Decimal

GetDecimal

nvarchar

String

Char[]

NVarChar

GetSqlString

String

GetString

GetChars

real

Single

Real

GetSqlSingle

Single

GetFloat

rowversion

Byte[]

Timestamp

GetSqlBinary

Binary

GetBytes

smalldatetime

DateTime

DateTime

GetSqlDateTime

DateTime

GetDateTime

smallint

Int16

SmallInt

GetSqlInt16

Int16

GetInt16

smallmoney

Decimal

SmallMoney

GetSqlDecimal

Decimal

GetDecimal

sql_variant

Object*

Variant

GetSqlValue *

Object

GetValue *

text

String

Char[]

Text

GetSqlString

String

GetString

GetChars

时间

(SQL Server 2008 及以上版本)

TimeSpan

Time

Time

GetDateTime

timestamp

Byte[]

Timestamp

GetSqlBinary

Binary

GetBytes

tinyint

Byte

TinyInt

GetSqlByte

Byte

GetByte

uniqueidentifier

Guid

UniqueIdentifier

GetSqlGuid

Guid

GetGuid

varbinary

Byte[]

VarBinary

GetSqlBinary

Binary

GetBytes

varchar

String

Char[]

VarChar

GetSqlString

AnsiString ,String

GetString

GetChars

xml

Xml

Xml

GetSqlXml

Xml

* 如果已知 sql_variant 的基础类型,则使用特定的类型化访问器。