|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
SQL table data type
I need to pass a table selected in one sp to another stored procedure... i have posted in regards to this before however, I am not running sql server 2000 and the person I am developing this for is running sql server version 8. I have tried a bunch of things but ultimately what I'm looking to do is take the results set of select * from table, store it to a variable, and execute another stored procedure passing that variable along to the other sp... So here are my two procedures.... Can someone tell me if the reason that this won't work (error msg that I need to declare @table) is because I'm not running sql server 2000 or am I not passing the select statement to the parameter properly? If the reason has to do with the sql server 2000, could someone give me an example on how to pass the results of one table to another stored procedure?????
CREATE PROCEDURE PROCEDURE1 AS DECLARE @table TABLE (custlastname varchar(20), custfirstname varchar(20)) BEGIN INSERT INTO @table Select custlastname, custfirstname from tblcustomer exec PROCEDURE2 @table GO CREATE PROCEDURE PROCEDURE2 AS SELECT * from @table GO Last edited by justastef : July 21st, 2003 at 12:56 PM. |
|
#2
|
|||
|
|||
|
I _think_ you would need to use global session variables.
Basically you'd delcare @@table table. I'm not entirely sure that would work, but give it a shot. |
|
#3
|
||||
|
||||
|
You could build the string manually and then exec it.
Code:
CREATE PROCEDURE PROCEDURE2
@tablename CHARACTER VARYING(255)
AS
DECLARE @sql CHARACTER VARYING(2000)
SELECT @sql = 'SELECT * FROM ' + @tablename
EXEC (@sql)
GO
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by sizeablegrin, etienne141 and L7Sqr, superior C/C++ programmers of the month |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > SQL table data type |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|