search
HomeDatabaseMysql Tutorialsqlserver OpenRowSet 对应的三种数据库驱动

在使用sqlserver数据库的OpenRowSet函数时,会遇到三种驱动方式: 1. MSDASQL驱动 SELECT TOP 10 * FROM OPENROWSET('MSDASQL', 'DRIVER={SQL Server};SERVER=xxx;UID=xx;PWD=xxx;', 'select * from AdventureWorks.HumanResources.Employee') 2. SQLNCLI驱

在使用sqlserver数据库的OpenRowSet函数时,会遇到三种驱动方式:

1. MSDASQL驱动
SELECT TOP 10 *
FROM OPENROWSET('MSDASQL', 'DRIVER={SQL Server};SERVER=xxx;UID=xx;PWD=xxx;', 'select * from AdventureWorks.HumanResources.Employee')

2. SQLNCLI驱动
SELECT TOP 10 *
FROM OPENROWSET('SQLNCLI', 'SERVER=xxx;UID=xx;PWD=xxxxx;', 'select * from AdventureWorks.HumanResources.Employee')

3. SQLOLEDB驱动
SELECT TOP 10 *
FROM OpenRowSet('SQLOLEDB', 'xxx'; 'xx'; 'xxx', AdventureWorks.HumanResources.Employee)

先看一下定义

MSDASQL:Microsoft OLE DB Provider for ODBC Drivers

允许在 OLEDB 和 ADO(它在内部使用 OLEDB)上构建的应用程序通过 ODBC 驱动程序访问数据源的技术。
MSDASQL 是用于连接到 ODBC(而不是数据库)的 OLEDB 访问接口。

SQLOLEDB :Microsoft OLE DB Provider for SQL Server,可以看出来SQLOLEDB是连接到数据库sqlserver,而不是ODBC驱动

SQLNCLI10(SQLNCLI):SQL Server Native Client 10.0

SQL Server Native Client的定义:

SQL Server Native Client 是在 SQL Server 2005 中引入的用于 OLE DB 和 ODBC 的独立数据访问应用程序编程接口 (API)。SQL Server Native Client 将 SQL OLE DB 访问接口和 SQL ODBC 驱动程序组合成一个本机动态链接库 (DLL)。为了利用在 SQL Server 2005以及以上的版本的新功能,比如多个活动结果集 (MARS)、查询通知、用户定义类型 (UDT) 或新的 xml 数据类型,那些使用 ActiveX Data Objects (ADO) 的现有应用程序应当使用 SQL Server Native Client OLE DB 访问接口作为其数据访问接口。

如果不需要使用在 SQL Server 2005 及其以后的版本中引入的任何新功能,则不需要使用 SQL Server Native Client OLE DB 访问接口;您可以继续使用当前数据访问接口(通常是 SQLOLEDB)。如果要增强现有应用程序的功能,并且需要使用在 SQL Server 2005 及其以后的版本中引入的新功能,则应当使用 SQL Server Native Client OLE DB 访问接口。

附上 OPENROWSET 语法格式

OPENROWSET 
<strong>(</strong> { <strong>'</strong><em>provider_name</em><strong>'</strong> <strong>,</strong> { <strong>'</strong><em>datasource</em><strong>'</strong> <strong>;</strong> <strong>'</strong><em>user_id</em><strong>'</strong> <strong>;</strong> <strong>'</strong><em>password</em><strong>'</strong> 
   | <strong>'</strong><em>provider_string</em><strong>' </strong>} 
      <strong>,</strong> {   [ <em>catalog</em><strong>.</strong> ] [ <em>schema</em><strong>. </strong>] <em>object</em> 
       | <strong>'</strong><em>query</em><strong>'</strong> 
     } 
   | BULK <strong>'</strong><em>data_file</em><strong>'</strong> <strong>,</strong> 
       { FORMATFILE <strong>=</strong> <strong>'</strong><em>format_file_path</em><strong>'</strong> [ <bulk_options> ]
       | SINGLE_BLOB | SINGLE_CLOB | SINGLE_NCLOB }
} <strong>)</strong> 

<bulk_options> ::=
   [ <strong>,</strong> CODEPAGE <strong>=</strong> { <strong>'</strong>ACP<strong>'</strong> | <strong>'</strong>OEM<strong>'</strong> | <strong>'</strong>RAW<strong>'</strong> | <strong>'</strong><em>code_page</em><strong>'</strong> } ] 
   [ <strong>,</strong> ERRORFILE <strong>=</strong> <strong>'</strong><em>file_name</em><strong>'</strong> ]
   [ <strong>,</strong> FIRSTROW <strong>=</strong> f<em>irst_row </em>] 
   [ <strong>,</strong> LASTROW <strong>=</strong> la<em>st_row </em>] 
   [ <strong>,</strong> MAXERRORS <strong>=</strong> m<em>aximum_errors </em>] 
   [ <strong>,</strong> ROWS_PER_BATCH <strong>=</strong> <em>rows_per_batch </em>] <br><br>[ <strong>,</strong> ORDER ( { column [ ASC | DESC ] } [ <strong>,</strong>...<em>n</em> ] ) [ UNIQUE ] </bulk_options></bulk_options>

参照:http://www.cnblogs.com/w-y-f/archive/2012/05/07/2488474.html

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
MySQL BLOB : are there any limits?MySQL BLOB : are there any limits?May 08, 2025 am 12:22 AM

MySQLBLOBshavelimits:TINYBLOB(255bytes),BLOB(65,535bytes),MEDIUMBLOB(16,777,215bytes),andLONGBLOB(4,294,967,295bytes).TouseBLOBseffectively:1)ConsiderperformanceimpactsandstorelargeBLOBsexternally;2)Managebackupsandreplicationcarefully;3)Usepathsinst

MySQL : What are the best tools to automate users creation?MySQL : What are the best tools to automate users creation?May 08, 2025 am 12:22 AM

The best tools and technologies for automating the creation of users in MySQL include: 1. MySQLWorkbench, suitable for small to medium-sized environments, easy to use but high resource consumption; 2. Ansible, suitable for multi-server environments, simple but steep learning curve; 3. Custom Python scripts, flexible but need to ensure script security; 4. Puppet and Chef, suitable for large-scale environments, complex but scalable. Scale, learning curve and integration needs should be considered when choosing.

MySQL: Can I search inside a blob?MySQL: Can I search inside a blob?May 08, 2025 am 12:20 AM

Yes,youcansearchinsideaBLOBinMySQLusingspecifictechniques.1)ConverttheBLOBtoaUTF-8stringwithCONVERTfunctionandsearchusingLIKE.2)ForcompressedBLOBs,useUNCOMPRESSbeforeconversion.3)Considerperformanceimpactsanddataencoding.4)Forcomplexdata,externalproc

MySQL String Data Types: A Comprehensive GuideMySQL String Data Types: A Comprehensive GuideMay 08, 2025 am 12:14 AM

MySQLoffersvariousstringdatatypes:1)CHARforfixed-lengthstrings,idealforconsistentlengthdatalikecountrycodes;2)VARCHARforvariable-lengthstrings,suitableforfieldslikenames;3)TEXTtypesforlargertext,goodforblogpostsbutcanimpactperformance;4)BINARYandVARB

Mastering MySQL BLOBs: A Step-by-Step TutorialMastering MySQL BLOBs: A Step-by-Step TutorialMay 08, 2025 am 12:01 AM

TomasterMySQLBLOBs,followthesesteps:1)ChoosetheappropriateBLOBtype(TINYBLOB,BLOB,MEDIUMBLOB,LONGBLOB)basedondatasize.2)InsertdatausingLOAD_FILEforefficiency.3)Storefilereferencesinsteadoffilestoimproveperformance.4)UseDUMPFILEtoretrieveandsaveBLOBsco

BLOB Data Type in MySQL: A Detailed Overview for DevelopersBLOB Data Type in MySQL: A Detailed Overview for DevelopersMay 07, 2025 pm 05:41 PM

BlobdatatypesinmysqlareusedforvoringLargebinarydatalikeImagesoraudio.1) Useblobtypes (tinyblobtolongblob) Basedondatasizeneeds. 2) Storeblobsin Perplate Petooptimize Performance.3) ConsidersxterNal Storage Forel Blob Romana DatabasesizerIndimprovebackupupe

How to Add Users to MySQL from the Command LineHow to Add Users to MySQL from the Command LineMay 07, 2025 pm 05:01 PM

ToadduserstoMySQLfromthecommandline,loginasroot,thenuseCREATEUSER'username'@'host'IDENTIFIEDBY'password';tocreateanewuser.GrantpermissionswithGRANTALLPRIVILEGESONdatabase.*TO'username'@'host';anduseFLUSHPRIVILEGES;toapplychanges.Alwaysusestrongpasswo

What Are the Different String Data Types in MySQL? A Detailed OverviewWhat Are the Different String Data Types in MySQL? A Detailed OverviewMay 07, 2025 pm 03:33 PM

MySQLofferseightstringdatatypes:CHAR,VARCHAR,BINARY,VARBINARY,BLOB,TEXT,ENUM,andSET.1)CHARisfixed-length,idealforconsistentdatalikecountrycodes.2)VARCHARisvariable-length,efficientforvaryingdatalikenames.3)BINARYandVARBINARYstorebinarydata,similartoC

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.