Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.sqlserver.programming
external usenet poster
 
Posts: 23
Default How to pass an Excel range as an argument to a SQL Server stored Procedure

Hello All

I want to pass an Excel range data to a SQL Server stored procedure. I
am trying to pass the data in a Excel range in form of some VB array
to a stored procedure.

Can you kindly provide a simple sample code in VBA and in T-SQL stored
proc how I can do this.

Thanks
Belinda
  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.sqlserver.programming
external usenet poster
 
Posts: 11,272
Default How to pass an Excel range as an argument to a SQL Server stored Procedure

Belinda,

Are you reading an Excel worksheet? If so, this is usually like

SELECT * FROM [Sheet1$];

If you want to get a specific range, it is best to create a workbook name
for that range, and then it acts as a pseudo-table

SELECT * FROM myExcelRange;
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Belinda" wrote in message
om...
Hello All

I want to pass an Excel range data to a SQL Server stored procedure. I
am trying to pass the data in a Excel range in form of some VB array
to a stored procedure.

Can you kindly provide a simple sample code in VBA and in T-SQL stored
proc how I can do this.

Thanks
Belinda



  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.sqlserver.programming
external usenet poster
 
Posts: 1
Default How to pass an Excel range as an argument to a SQL Server stored Procedure

In order to do as Bob suggests, you must add the Excel spreadsheet as a
linked server ( this is doc'd in books on line.). THen use the 4 part name

select * from myexcel...namedrange


--
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)

I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org

"Belinda" wrote in message
om...
Hello All

I want to pass an Excel range data to a SQL Server stored procedure. I
am trying to pass the data in a Excel range in form of some VB array
to a stored procedure.

Can you kindly provide a simple sample code in VBA and in T-SQL stored
proc how I can do this.

Thanks
Belinda



  #4   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.sqlserver.programming
external usenet poster
 
Posts: 23
Default How to pass an Excel range as an argument to a SQL Server stored Procedure

Wayne & Bob

Many thanks for your tip on reading a Excel range. Please note I have
a number of users using Excel and will need to writeback to SQL Server
creating a linked server using OpenDataSource will need the Excel file
to be on the server where SQL Server is running. So that means I must
ensure all these Excel updates from Clients must be saved onto a Excel
file on the SQL Server or on a network share to be available to SQL
Server this will greatly reduce concurrency of users running this
Excel to SQL Server writeback app and also they would need a network
access to a shared drive or to the server where SQL Server is located.
I would like to read the range in VBA and pass it to a stored proc
through ADO that way my application will have concurrency and
scalability.

Can you please suggest how I can pass a Excel range from VBA to a
T-SQL stored proc.

Thanks
Belinda

"Wayne Snyder" wrote in message ...
In order to do as Bob suggests, you must add the Excel spreadsheet as a
linked server ( this is doc'd in books on line.). THen use the 4 part name

select * from myexcel...namedrange


--
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)

I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org

"Belinda" wrote in message
om...
Hello All

I want to pass an Excel range data to a SQL Server stored procedure. I
am trying to pass the data in a Excel range in form of some VB array
to a stored procedure.

Can you kindly provide a simple sample code in VBA and in T-SQL stored
proc how I can do this.

Thanks
Belinda

  #5   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.sqlserver.programming
external usenet poster
 
Posts: 11,272
Default How to pass an Excel range as an argument to a SQL Server stored Procedure

Belinda,

What does the range hold, a set of dates, text, numbers, or what? What does
the SP expect, one at a time, an array? I have an example of reading from a
Sybase database using SPs, SQL Server uses Transact-SQL same as Sybase,
writing would be the same principle. Only change would be the connection
string.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Belinda" wrote in message
om...
Wayne & Bob

Many thanks for your tip on reading a Excel range. Please note I have
a number of users using Excel and will need to writeback to SQL Server
creating a linked server using OpenDataSource will need the Excel file
to be on the server where SQL Server is running. So that means I must
ensure all these Excel updates from Clients must be saved onto a Excel
file on the SQL Server or on a network share to be available to SQL
Server this will greatly reduce concurrency of users running this
Excel to SQL Server writeback app and also they would need a network
access to a shared drive or to the server where SQL Server is located.
I would like to read the range in VBA and pass it to a stored proc
through ADO that way my application will have concurrency and
scalability.

Can you please suggest how I can pass a Excel range from VBA to a
T-SQL stored proc.

Thanks
Belinda

"Wayne Snyder" wrote in message

...
In order to do as Bob suggests, you must add the Excel spreadsheet as a
linked server ( this is doc'd in books on line.). THen use the 4 part

name

select * from myexcel...namedrange


--
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)

I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org

"Belinda" wrote in message
om...
Hello All

I want to pass an Excel range data to a SQL Server stored procedure. I
am trying to pass the data in a Excel range in form of some VB array
to a stored procedure.

Can you kindly provide a simple sample code in VBA and in T-SQL stored
proc how I can do this.

Thanks
Belinda





  #6   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.sqlserver.programming
external usenet poster
 
Posts: 459
Default How to pass an Excel range as an argument to a SQL Server stored Procedure

I don't think you can pass an array as a parameter of a stored
procedure. The usual advice is to use a delimited string i.e.
concatenate the range values using appropriate characters as
delimiters for column and row e.g.

"a1,b1,c1;a2,b2,c2;a3,b3,c3"

where , delimits columns and ; delimits rows (assumes there are no ,
nor ; in your data). Your stored proc should then parse the string to
retireve the cell values.

--

(Belinda) wrote in message . com...
Wayne & Bob

Many thanks for your tip on reading a Excel range. Please note I have
a number of users using Excel and will need to writeback to SQL Server
creating a linked server using OpenDataSource will need the Excel file
to be on the server where SQL Server is running. So that means I must
ensure all these Excel updates from Clients must be saved onto a Excel
file on the SQL Server or on a network share to be available to SQL
Server this will greatly reduce concurrency of users running this
Excel to SQL Server writeback app and also they would need a network
access to a shared drive or to the server where SQL Server is located.
I would like to read the range in VBA and pass it to a stored proc
through ADO that way my application will have concurrency and
scalability.

Can you please suggest how I can pass a Excel range from VBA to a
T-SQL stored proc.

Thanks
Belinda

  #7   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.sqlserver.programming
external usenet poster
 
Posts: 1
Default How to pass an Excel range as an argument to a SQL Server stored Procedure

Can I do the reverse? INSERT INTO myexcel...namedrange SELECT x, y, z, FROM
mytable?

"Wayne Snyder" wrote in message
...
In order to do as Bob suggests, you must add the Excel spreadsheet as a
linked server ( this is doc'd in books on line.). THen use the 4 part name

select * from myexcel...namedrange


--
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)

I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org

"Belinda" wrote in message
om...
Hello All

I want to pass an Excel range data to a SQL Server stored procedure. I
am trying to pass the data in a Excel range in form of some VB array
to a stored procedure.

Can you kindly provide a simple sample code in VBA and in T-SQL stored
proc how I can do this.

Thanks
Belinda





  #8   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.sqlserver.programming
external usenet poster
 
Posts: 459
Default How to pass an Excel range as an argument to a SQL Server stored Procedure

"George Hutto" wrote in message ...
Can I do the reverse? INSERT INTO myexcel...namedrange SELECT x, y, z, FROM
mytable?


Sure can. Run this query against a MS Jet connection:

INSERT INTO
[Excel 8.0;database=C:\myexcel.xls;].[namedrange]
SELECT x, y, z
FROM
[ODBC;Driver={SQL
Server};SERVER=MYSERVER;DATABASE=MyDB;UID=;Pwd=;].mytable

Note myexcel.xls should be closed to avoid the memory leak bug
(Q319998).

You can do something similar in SQL on the server side but I can't
remember the exact syntax off the top of my head.

--
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
How can Oracle DB Stored procedure be called in MS Excel? Amol Excel Discussion (Misc queries) 1 January 7th 07 10:05 AM
execute stored procedure from excel maxzsim Excel Worksheet Functions 3 May 11th 05 04:58 PM
Importing Data from a Stored Procedure (SQL SErver) Martin Eckart Excel Programming 1 January 22nd 04 01:24 AM
How can I grab data from a SQL Server stored procedure Sam Excel Programming 3 December 4th 03 03:38 PM
Passing parameter from Excel to stored procedure? hmmm... Excel Programming 1 July 25th 03 02:59 PM


All times are GMT +1. The time now is 03:44 AM.

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"