July 20, 2004 06:20 PM

Bulk-Insert Options for ADO.NET

Rating: (0)
SQL Server Magazine
InstantDoc ID #43063
Clients commonly ask me how to bulk insert data into SQL Server from ADO.NET applications. There's no easy answer to this question because ADO.NET doesn't have any built-in bulk-insert objects. The most straightforward method for performing bulk-insert operations from ADO.NET is loading the DataSet with multiple large groups of rows, then sending updates to SQL Server. You can also use the SqlCommand object inside either a stored procedure or a parameterized INSERT statement to insert the data. ...

...This article is for paid Professional Members only.

Already a Professional Member? Please log in now:

NOT A PROFESSIONAL MEMBER? YOU CHOOSE:

Professional Membership

Monthly

Annual

VIP Membership

Monthly

Annual

Add a Comment

Mr Otey,

I read your article about using ODBC from ADO.Net. I wonder if the equivalent of ODBC/Bulkcopy librairies exists under .NET. Your article doesn't mention that. We used them recently the get BCP.EXE invocation out of our programming. Theses librairies are quite easy to use. You can find information under under theses sections in books online :
Building SQL Server Applications / ODBC and SQL Server / Programming ODBC SQL Server Applications / Performing Bulk Copy operations
AND
How-to / ODBC / How to bulk copy with the SQL Server ODBC driver (ODBC)

These functions are derived from dblib's way of doing things, but where adapted for ODBC. Among them there are bcp_init that receive an ODBC connection handle, bcp_exec that uses the same handle and is able to load native BCP files. There is also bcp_colfmt that help to specify column type and delimiter when bcp file is not native. There are many other functions that help control natively bulk copy behavior.

Your VC++ project must include odbcbcp.lib and the includes "sqlext.h" and "odbcss.h".

T-SQL Bulk insert is interesting only if you can put your BCP files on SQL Server or if SQL Server can access another server share where thoses files are located.

Maurice7/26/2004 9:26:46 AM


You must log on before posting a comment.

Are you a new visitor? Register Here
GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS