Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old July 21st, 2003, 12:53 PM
justastef justastef is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 16 justastef User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old July 21st, 2003, 01:40 PM
twifosp twifosp is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 7 twifosp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #3  
Old July 21st, 2003, 02:00 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is online now
Banned ;)
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,442 Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 h 26 m 13 sec
Reputation Power: 797
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > SQL table data type


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway