locked
Excel to SQL Server (SqlBulkCopy method) RRS feed

  • Question

  • Dear all,

    Does anybody have a method writing (in bulk) a named range or sheet to SQL server from Excel 2010?

    I have 100000 to 300000 records I want to write to SQL Server from an Excel model and looping through each record loaded into an array is too slow.

    Im suspecting I need to use a SqlBulkCopy method from Excel or similar but how?

    It should be something similar to this link but written in VBA code and run from the workbook:
    http://davidhayden.com/blog/dave/archive/2006/05/31/2976.aspx

    I can do most things in VBA but SQL or .NET is not my strong side to be modest.

    BR

    Marc Bruun

    Friday, September 30, 2011 3:27 PM

Answers

  • I looked around and didn't find a method of accessing the SqlBulkCopy class directly from Excel VBA.  I think you need to write a simple addin in Visual Studio Using David Haydens code.
    jdweng
    • Marked as answer by Calvin_Gao Monday, October 10, 2011 12:37 PM
    Friday, September 30, 2011 7:54 PM