Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Importing Excel data with macros to SQL server

Hi All,

I need to import an excel sheet data to sql server.
I have imported each sheet in excel sheet into a table in sql server and I
have made a proper relation between tables.
I found a function written in vb, that updates the cells when I click on a
button on the sheet.
I need to convert this code into a stored procedure or function in sql
server.
Can anyone please help me how to achieve this?

Thanks in advance,
Rams.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Importing Excel data with macros to SQL server

to me there are two issues.

Are you asking what the code is to oush the data to SQl and also how to
convert that code to an sp?

the sql would be quite simplistic

INSERT INTO {tablename} ({field1},{field2} ..) VALUES ( value1. value2...)

read sql help on savign this as an sp.

now in the excel code editor, set a reference the Microsoft active data
objects 2.7 Library

create a new connetcion, then with a command object, execute the sql


Dim con As New ADODB.Connection
sSQL="INSERT INTO {tablename} ({field1},{field2} ..) VALUES ( value1.
value2...)"


With con
.ConnectionString ="{your connection string}"
.Open
End With
With New Command
.ActiveConnection = con
.CommandType = adCmdText
.CommandText = sSQL
.Execute
Debug.Print .Properties.Count
End With
con.Close


oce you have the SP, then yuor sql would haev to be changed to somethign
along these lines
sp_myInsert a,b,c











"ramszone" wrote:

Hi All,

I need to import an excel sheet data to sql server.
I have imported each sheet in excel sheet into a table in sql server and I
have made a proper relation between tables.
I found a function written in vb, that updates the cells when I click on a
button on the sheet.
I need to convert this code into a stored procedure or function in sql
server.
Can anyone please help me how to achieve this?

Thanks in advance,
Rams.

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
importing data from excel to sql server 2008 by code at run time Ammar S. Mitoori Excel Programming 2 August 13th 09 09:42 AM
importing alphanumeric columns from excel into SQL-Server or MS-Ac herbert Excel Programming 2 May 14th 07 04:39 PM
Problem importing data into sql server database Me Excel Discussion (Misc queries) 1 January 27th 06 01:51 AM
Importing Data from a Stored Procedure (SQL SErver) Martin Eckart Excel Programming 1 January 22nd 04 01:24 AM
Importing data from an Excel file on a web server using ADO/VBA Dean Frazier Excel Programming 0 November 13th 03 12:39 AM


All times are GMT +1. The time now is 01:29 AM.

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"