sqlserver 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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The import steps are as follows: Copy the MDF file to SQL Server's data directory (usually C:\Program Files\Microsoft SQL Server\MSSQL\DATA). In SQL Server Management Studio (SSMS), open the database and select Attach. Click the Add button and select the MDF file. Confirm the database name and click the OK button.

If you accidentally delete a SQL Server database, you can take the following steps to recover: stop database activity; back up log files; check database logs; recovery options: restore from backup; restore from transaction log; use DBCC CHECKDB; use third-party tools. Please back up your database regularly and enable transaction logging to prevent data loss.

If the SQL Server installation fails, you can clean it up by following these steps: Uninstall SQL Server Delete registry keys Delete files and folders Restart the computer

SQL Server English installation can be changed to Chinese by following the following steps: download the corresponding language pack; stop the SQL Server service; install the language pack; change the instance language; change the user interface language; restart the application.

The syntax differences between MySQL and SQL Server are mainly reflected in database objects, data types, SQL statements and other aspects. Database object differences include the storage engine and how filegroups are specified, and the creation of indexes and constraints. Data type differences involve differences in numeric types, character types, and date and time types. SQL statement differences are reflected in result set limitations, data insertion, update and delete operations, etc. Other differences include how identity columns, views, and stored procedures are created. Understanding these differences is important to avoid errors when using different database systems.

To delete a SQL Server database, please perform the following steps in sequence: 1. Log in to SQL Server Management Studio; 2. Expand the database node; 3. Right-click the database to be deleted; 4. Select "Delete"; 5. Confirm the deletion. Note: Deleting the database is irreversible, please make sure you have backed up important data and disconnected other objects.

SQL Server deleted data can be recovered through transaction rollback (rolling back uncommitted transactions). Database log (restore data from log). SQL Server native backup (restore database from backup). Third-party recovery tools (use advanced technology to recover data). Contact Microsoft Support (for dedicated help).

The problem that SQL Server cannot be reinstalled due to incomplete deletion can be solved by following the following steps: manually delete files and registry entries; use SQL Server installation and uninstall tools; use third-party uninstall tools; check Windows Event Viewer; restart the computer; reinstall SQL Server.
