Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Excel to SQL Script

Hello,
Is there some function/utility/etc. that will read a row of Excel data, and
create a file with SQL statements to load the data into SQL? We want to
avoid using ADO and the traditional "insert" method.

--
Programmer on Budget
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Excel to SQL Script

Hi BP,

Budget Programmer wrote:
Hello,
Is there some function/utility/etc. that will read a row of Excel
data, and create a file with SQL statements to load the data into
SQL? We want to avoid using ADO and the traditional "insert" method.


If you're talking about importing the data into SQL Server, you can use DTS
or BCP to import the data directly from Excel into SQL Server.

If it's a limited # of rows of data, I typically dynamically generate the
INSERT statements using Excel, then copy/paste the resulting script into the
SQL SMS and execute it from there.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Excel to SQL Script

Just to follow up on what I meant by dynamic script generation, let's assume
we have this data in a worksheet (A1:C3):

ID Name Phone
1 Jake 555-1212
2 John 555-1213

In D2, you could use a formula like this:

="INSERT INTO dbo.Employees ([" & $A$1 & "], [" & $B$1 & "], [" & $C$1 & "])
VALUES (" & $A2 & ", '" & $B2 & "', '" & $C2 & "')"

and copy it down to D3. This would result in the following 2 SQL stmts in
D2:D3:

INSERT INTO dbo.Employees ([ID], [Name], [Phone]) VALUES (1, 'Jake',
'555-1212')
INSERT INTO dbo.Employees ([ID], [Name], [Phone]) VALUES (2, 'John',
'555-1213')

Which you could then copy into any SQL editor to execute them against the
server.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]


Jake Marx wrote:
Hi BP,

Budget Programmer wrote:
Hello,
Is there some function/utility/etc. that will read a row of Excel
data, and create a file with SQL statements to load the data into
SQL? We want to avoid using ADO and the traditional "insert" method.


If you're talking about importing the data into SQL Server, you can
use DTS or BCP to import the data directly from Excel into SQL Server.

If it's a limited # of rows of data, I typically dynamically generate
the INSERT statements using Excel, then copy/paste the resulting
script into the SQL SMS and execute it from there.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Excel to SQL Script

Jake,
Thanks for your help.
--
Programmer on Budget


"Jake Marx" wrote:

Just to follow up on what I meant by dynamic script generation, let's assume
we have this data in a worksheet (A1:C3):

ID Name Phone
1 Jake 555-1212
2 John 555-1213

In D2, you could use a formula like this:

="INSERT INTO dbo.Employees ([" & $A$1 & "], [" & $B$1 & "], [" & $C$1 & "])
VALUES (" & $A2 & ", '" & $B2 & "', '" & $C2 & "')"

and copy it down to D3. This would result in the following 2 SQL stmts in
D2:D3:

INSERT INTO dbo.Employees ([ID], [Name], [Phone]) VALUES (1, 'Jake',
'555-1212')
INSERT INTO dbo.Employees ([ID], [Name], [Phone]) VALUES (2, 'John',
'555-1213')

Which you could then copy into any SQL editor to execute them against the
server.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]


Jake Marx wrote:
Hi BP,

Budget Programmer wrote:
Hello,
Is there some function/utility/etc. that will read a row of Excel
data, and create a file with SQL statements to load the data into
SQL? We want to avoid using ADO and the traditional "insert" method.


If you're talking about importing the data into SQL Server, you can
use DTS or BCP to import the data directly from Excel into SQL Server.

If it's a limited # of rows of data, I typically dynamically generate
the INSERT statements using Excel, then copy/paste the resulting
script into the SQL SMS and execute it from there.




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
help with EXCEL SCRIPT Nastech Excel Discussion (Misc queries) 16 October 25th 08 04:46 AM
help with EXCEL SCRIPT Nastech Excel Discussion (Misc queries) 0 October 20th 08 04:54 AM
I need a VB script for Excel pretextat Excel Programming 5 July 21st 06 01:20 AM
Excel 2000/XP script to Excel97 script hat Excel Programming 3 March 2nd 04 03:56 PM
VBA Script in Excel k1appy Excel Programming 1 December 30th 03 01:46 PM


All times are GMT +1. The time now is 03:09 PM.

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

About Us

"It's about Microsoft Excel"