Native Data Access for SQL Server 2005 FAQ

Native Data Access for SQL Server 2005 FAQ

In SQL Server 2005 Microsoft decided to change the way it supports ODBC and OLE DB with the introduction of Microsoft SQL Server Native Client (SQL Native Client), a new component of SQL Server 2005. This FAQ answers some basic questions about SQL Native Client and about ODBC and OLE DB in general.

What is SQL Native Client?

Microsoft SQL Server Native Client (SQL Native Client) is a single native dynamic link library (DLL) that contains the ODBC driver and OLE DB provider which together support applications using native-code APIs (ODBC, OLE DB and ADO) to access Microsoft SQL Server. SQL Native Client is a component of SQL Server 2005 and is serviced in SQL Server 2005 service packs. It is also available for download from MSDN ( In SQL Native Client, everything (APIs, TDS routines and netlibs) is packaged into a single DLL.

Previously ODBC and OLE DB support for SQL Server was provided via Microsoft Data Access Components (MDAC - MDAC is now fully integrated into Windows and is available only in Windows releases and service packs – there will be no more standalone MDAC downloads on MSDN. MDAC continues to provide core data access functionality such as the ODBC Driver Manager and OLE DB Core Services, but the ODBC and OLE DB support for SQL Server is frozen at the level of functionality provided by SQL Server 2000.

Note that SQL Native Client supports SQL Server releases from SQL Server 7.0 onwards, so its use is not restricted to SQL Server 2005. However, new features such as MARS ( are only available when connected to SQL Server 2005.

Where do I find out more about SQL Native Client?

You can find information about SQL Native Client in Books Online and also on MDSN (

For anything you can’t find there you can use the SQL Server Data Access forum (

Must I upgrade clients to use SQL Native Client as soon as I upgrade my server?

Applications deployed before SQL Server 2005 was released can and should continue to use MDAC.

Applications must upgrade to take full advantage of the new features and data types introduced in SQL Server 2005 ( ). When an application is upgraded, it should be thoroughly tested since there are some differences in behavior between MDAC and SQL Native Client ( ). The vast majority of applications will not be affected by these changes, but this does not remove the responsibility to test before deployment.

Should I rewrite my native API applications to use ADO.Net and managed code?

In most cases the old adage “If it isn’t broken, don’t fix it” applies. The .Net platform has many compelling attributes and will be the right choice for new development in most cases, but this does not mean that it is the right choice in all cases. There are valid reasons for making other choices in some case: Visual Studio 2005 and C++/CLI ( re-use of existing native data access code within a .Net deployment infrastructure a more viable option than ever before; there are some scenarios where native code and native APIs provide the best solution; Microsoft now has its own high quality JDBC driver for SQL Server 2005(; also, Native XML Web Services in SQL Server 2005 ( ) provide an additional means of exposing database-dependent services in service oriented architectures.

Isn’t ODBC is on the way out? If you have to use a native API isn’t OLE DB better?

ODBC and OLE DB are supported equally in SQL Native Client. Neither is better, they service different requirements and communities. There is no need to convert from one to the other unless there are other compelling business reasons. While there was a time when Microsoft expected OLE DB to supersede ODBC that time has passed and we now recognize that each API has its place.

OLE DB is a good choice for COM applications and has broader functionality than ODBC in some areas. It is used extensively within SQL Server itself. However, it is quite complex and more difficult to program for basic operations than ODBC.

ODBC may have been out of the limelight in recent years, but Microsoft anticipates strong and continued interest in this API going forward. ODBC has a huge following across the entire software industry and will therefore remain an essential component of SQL Server to meet requirements for standards alignment and interoperability. When migrating applications from other databases to SQL Server, where companies choose to re-use existing code and applications rather than make a fresh start and re-develop from scratch, ODBC will be the natural choice in most cases.

There is little difference in performance between OLE DB and ODBC – application architecture is likely to have a bigger impact on performance than choice of API for well-written applications that follow best practice guidelines.

Isn't ODBC just a ‘wrapper’ API and inherently inefficient?

This may be true for some ODBC drivers, but not for SQL Native Client. ODBC in SQL Native Client and also in MDAC is a true native API for SQL Server.

What about DB-Library and Embedded SQL for C(ESQL/C)?

DB-Library and ESQL/C components are not included in SQL Server 2005 but connections from existing applications are supported. Microsoft has no plans for any new development work involving these APIs. Customers may continue to deploy existing applications, but development of new applications and extension of existing applications is not recommended. Continued support for DB-Library and ESQL/C is not guaranteed in future releases of SQL Server ( ).

Microsoft is reviewing support for DB-Library and ESQL/C in future releases of SQL Server and welcomes your input as part of the review process.

Chris Lee
Program Manager, SQL Native Client

Comments (10)

  1. josvazg says:

    I have to write a small DLL to access a SQL Server (calling some stored procedures) for an embedded environment. I already wrote a similar DLL for PostgreSQL and it was very easy to find the API (libpq and write the code…

    Why is this so difficult for MSSQL?

    Where do I get code samples for accessing MSSQL server from plain old C code.

    If impossible, is there something for C++ code? (I can always hide the C++ from the DLL users)

    Is it possible to access a remote MSSQL WITHOUT having to configure the ODBC source OUTSIDE your code. I mean just saying the DB server host, port, dbname and user/passwd? (Just as JDBC DOES, for example, give it a URL or connection string and be done with it)

    Where can I get some help, API docs on this?

  2. MSDN Archive says:


    The result of replace() is returned as nvarchar(max). nvarchar(max) has unlimited size and ODBC represents this by returning a column size of 0. This can confuse applications which don’t check for 0 as a special case and do buffer size arithmetic based on the column size returned by SQLDescribeCol or similar calls. I suspect the application is binding a buffer that only has space for the null terminator and is getting a truncation warning from ODBC as a consequence. When you cast the result to a fixed size varchar type SQLBindCol returns a column size matching the cast and the application then binds a buffer that is big enough for the result.

    Chris Lee

  3. smois says:


    We have connection to SS2005 from PhP using SQL Native Client.

    Issue is that some queries (for example, of "FOR XML" type) give unexpected result set. Thus, query

    select top 1 replace(replace((select ‘abc’ as [data]

    from pc

    for xml path(”)), ‘<data>’, ”),'</data>’,”)

    which must give


    gives something like this


    whereas using ODBC gives correct result set.

    Can you help me to clear the issue?

    One can see this odd result of above query at

    (click "enter without login" , then mark "without checking", paste the above query and click Run button).

    Additional information:

    The following query works:

    select top 1


    replace(replace((select ‘abc’ as [data]

    from pc

    for xml path(”)), ‘<data>’, ”),'</data>’,”)

    as varchar(8000))

    Above without CAST does not work.



    select top 1 cast(replace(replace((select ‘abc’ as [data]

    from pc

    for xml path(”)), ‘<data>’, ”),'</data>’,”) as varchar(max))

    does not work.


    Sergey Moiseenko

Skip to main content