Hi,
apologies if this has been asked before.

I'm trying to insert a range of data in Excel to a table in SQL Server. I have some VBA code that loops through each row and executes an Insert statement to the table, and this works. However, I'm trying to find a more flexible solution.

I have a Stored Proc in SQL Server that takes a Table Valued Parameter and inserts all of the records in the parameter to the table.


Please Login or Register  to view this content.
I'd like to pass the range e.g. A2:F4 to the Stored Proc in VBA as a parameter but can't seem to find a way to do it. I'd be grateful for any ideas/code snippets folks might have.

As an alternative I can package the range into an XML string and pass that to the Stored Proc but I'd rather leave it as it is with the TVP.

Thanks,
Sean