Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default push recordset from excel to SQL server

Hello,

I've searched but cannot find. There are many posts discussing
populating a spreadsheet from a recordset. I want to do the reverse.

1) select XL data into a recordset (call it "rsxl")
2) insert into an SQL server table the data from "rsxl"

Any help here is appreciated!

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default push recordset from excel to SQL server

Since I have not written data to SQL Server I will have to speak in
generalities here. Take a look at ADODB Recordsets. Create your recordset.
Connect to your database table and then update the table with the recordset.
Here is a link to get you started...

http://www.erlandsendata.no/english/...php?t=envbadac
--
HTH...

Jim Thomlinson


"Dave" wrote:

Hello,

I've searched but cannot find. There are many posts discussing
populating a spreadsheet from a recordset. I want to do the reverse.

1) select XL data into a recordset (call it "rsxl")
2) insert into an SQL server table the data from "rsxl"

Any help here is appreciated!

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default push recordset from excel to SQL server

You can loop through the Excel table, interface with a parameterized stored
procedure using ADO to send inserts.

If this is a one-off, you can loop through the XL table and write Insert
statements to a worksheet, since SQL Server supports multiple SQL
statements, e.g.
Insert into Table (field1, field2) values (1,2)
Insert into Table (field1, field2) values (1,3)
Insert into Table (field1, field2) values (1,3)
and just paste all that into the query window and execute it all at once.

You could create dynamic SQL and use ADO, but that's probably not suitable
for a production environment. See "The curse and blessings of dynamic SQL"
at http://www.revealnet.com/newsletter-v3/0402_F.htm

You can use the Bulk Copy Process or SQL Server Integration Services (the
replacement for DTS) and import the data into a table.
But SSIS requires so much configuration I'd much rather use a flexible
stored procedure and go row-by-row unless you are talking about
tens-of-thousands of rows frequently. If you have a fast connection (e.g.
you're connected directly to the network and not connecting through a VPN),
the inserts will be very very fast.

Just some ideas.


--
Tim Zych
www.higherdata.com
Compare data in worksheets and find differences with Workbook Compare
A free, powerful, flexible Excel utility


"Dave" wrote in message
...
Hello,

I've searched but cannot find. There are many posts discussing
populating a spreadsheet from a recordset. I want to do the reverse.

1) select XL data into a recordset (call it "rsxl")
2) insert into an SQL server table the data from "rsxl"

Any help here is appreciated!

Thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
best way to get an updatable SQL Server 2000 recordset into Excel? Eric Bragas[_2_] Excel Programming 2 February 8th 08 10:50 AM
Posting Recordset to SQl Server Candyman Excel Programming 0 June 29th 07 08:56 PM
SQL Server -- Bulk Insert from Excel to SQL Server Madhan Excel Discussion (Misc queries) 0 December 12th 06 03:08 PM
Excel 2003 Error Cannot Locate the Internet Server or Proxy Server Seabee Excel Discussion (Misc queries) 0 November 20th 05 12:03 AM
Error when opening recordset of SQL Server via ADO Glenn Ray[_3_] Excel Programming 0 September 2nd 05 11:00 PM


All times are GMT +1. The time now is 01:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"