Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 3
Default How can I grab data from a SQL Server stored procedure

Hi,

I want to place an excel sheet on our corporate portal site that connects to
a stored procedure on SQL Server 2000, passess two parameters and grabs
data.

When I connected to SQL Server, I was able to see tables and views but not
stored procedures. How can I connect to the DB and grab data from a stored
procedure? Thanks,

Sam


  #2   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 3
Default How can I grab data from a SQL Server stored procedure

Hey Patrick,

Thanks for your response. I'm connecting to the data source through a DSN.

My parameters will have different values every time user runs the SP. The
question is will I be able to pass these paramaters to Excel so that it will
pass them to the SP and receive the results

Thanks,

Sam
"Patrick Molloy" wrote in message
...
you don't explain how you connected tot he DB, but it
sounds like you're using Query Analyser.

A VIEW works much like a table, though it allows a
greater degree of complexity. A VIEW is also, a "view"
like a table...hence the rather obvious name.
Stored Procedures on the other hand need executing...much
a you would a procedure in VB/VBA
SP's offer a high degree of flexibility - its rather like
writing VB code, but using TSQL instead of VB, but its
very similar.
In Query Analyser type in the SP name, followed by any
parameters then hit F5

In VB/VBA once you've set an ADO connection to the
database, you can populate a recordset by Opening it with
some sql code
eg
"SELECT * FROM MyTable"
or if it's an SP
"usp_My_Stored_Proc"

if the sp returns a table, then your recordset will be
populated


Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
Hi,

I want to place an excel sheet on our corporate portal

site that connects to
a stored procedure on SQL Server 2000, passess two

parameters and grabs
data.

When I connected to SQL Server, I was able to see tables

and views but not
stored procedures. How can I connect to the DB and grab

data from a stored
procedure? Thanks,

Sam


.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default How can I grab data from a SQL Server stored procedure

That's a bit confusing.
A DSN is simply th econnection.
You pass parameters TO the database SP FROM Excel

SQL = "sp_MyStoredProc " & param1 [ & "," & Param2 ]...

OR

SQL = "SELECT * From " & sTableName
SQL = SQL & " WHERE " & param1 & "='" & condition1 & "';"


Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
Hey Patrick,

Thanks for your response. I'm connecting to the data

source through a DSN.

My parameters will have different values every time user

runs the SP. The
question is will I be able to pass these paramaters to

Excel so that it will
pass them to the SP and receive the results

Thanks,

Sam
"Patrick Molloy" wrote in

message
...
you don't explain how you connected tot he DB, but it
sounds like you're using Query Analyser.

A VIEW works much like a table, though it allows a
greater degree of complexity. A VIEW is also, a "view"
like a table...hence the rather obvious name.
Stored Procedures on the other hand need

executing...much
a you would a procedure in VB/VBA
SP's offer a high degree of flexibility - its rather

like
writing VB code, but using TSQL instead of VB, but its
very similar.
In Query Analyser type in the SP name, followed by any
parameters then hit F5

In VB/VBA once you've set an ADO connection to the
database, you can populate a recordset by Opening it

with
some sql code
eg
"SELECT * FROM MyTable"
or if it's an SP
"usp_My_Stored_Proc"

if the sp returns a table, then your recordset will be
populated


Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
Hi,

I want to place an excel sheet on our corporate portal

site that connects to
a stored procedure on SQL Server 2000, passess two

parameters and grabs
data.

When I connected to SQL Server, I was able to see

tables
and views but not
stored procedures. How can I connect to the DB and

grab
data from a stored
procedure? Thanks,

Sam


.



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default How can I grab data from a SQL Server stored procedure

Using ADO, you can use a Command object's Parameters collection.

Alternatively, you may be able to use the Connection object directly.
I've seen evidence (but can't recall where!) that this approach has
performance benefits. However the syntax seems a bit hit-and-miss. For
details see the section 'Execute a command as a native method of a
Connection object' in the documentation:-

ADO 2.8 API Reference: Connection Object:
http://msdn.microsoft.com/library/de...mdaobj01_7.asp

--

"Sam" wrote in message ...
Hey Patrick,

Thanks for your response. I'm connecting to the data source through a DSN.

My parameters will have different values every time user runs the SP. The
question is will I be able to pass these paramaters to Excel so that it will
pass them to the SP and receive the results

Thanks,

Sam
"Patrick Molloy" wrote in message
...
you don't explain how you connected tot he DB, but it
sounds like you're using Query Analyser.

A VIEW works much like a table, though it allows a
greater degree of complexity. A VIEW is also, a "view"
like a table...hence the rather obvious name.
Stored Procedures on the other hand need executing...much
a you would a procedure in VB/VBA
SP's offer a high degree of flexibility - its rather like
writing VB code, but using TSQL instead of VB, but its
very similar.
In Query Analyser type in the SP name, followed by any
parameters then hit F5

In VB/VBA once you've set an ADO connection to the
database, you can populate a recordset by Opening it with
some sql code
eg
"SELECT * FROM MyTable"
or if it's an SP
"usp_My_Stored_Proc"

if the sp returns a table, then your recordset will be
populated


Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
Hi,

I want to place an excel sheet on our corporate portal

site that connects to
a stored procedure on SQL Server 2000, passess two

parameters and grabs
data.

When I connected to SQL Server, I was able to see tables

and views but not
stored procedures. How can I connect to the DB and grab

data from a stored
procedure? Thanks,

Sam


.

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
Data return from SQL Stored procedure... Jonathon Shull Excel Discussion (Misc queries) 0 July 29th 08 04:25 PM
hyperlink, macro, stored procedure? JICDB Excel Worksheet Functions 5 October 27th 07 12:18 AM
Extract data from Stored procedure anu_manu Excel Discussion (Misc queries) 0 February 15th 06 02:49 PM
How do I access data stored in a SQL server for vlookup function? M.Heer Excel Worksheet Functions 8 May 12th 05 09:51 PM
Execute stored procedure using DAO sapta wijaya Excel Programming 0 September 29th 03 04:24 AM


All times are GMT +1. The time now is 01:30 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"