Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Using tables for geting it from number of st.proc.

Author  Topic 

kaspiton
Starting Member

1 Post

Posted - 2002-07-01 : 05:08:19
Hello!

I have some stored procedure:
exec sp_aaa

Within sp_aaa i call to second stored procedure (sp_aaa_1),
that create table and fill it by some integer values.
The name of table i generate by (newid() function).
It`s not a temporary table becouse i want use this table in
other stored procedure (sp_aaa_2).
Into sp_aaa_2 stored procedure i pass name of the table that was created in sp_aaa_1, and declare @t table variable, that i fill by
all values of table that was created in sp_aaa_1.

Like that i want to simulate pass table parameters in stored procedures, i can`t pass tables in stored procedures.

In stored procedure sp_aaa_2 i need do next
-------------------------------------
create stored procedure sp_aaa_1
@table_name uniqueidentifier
as

declare @t table (var_id int not null)
insert into @t (var_id)
exec ('select id from ' + @table_name)

select 1 as tag, null as parent,
c1.id as [somename!1!id],
c1.name as [somename!1!name]
from continents c1
inner join @t t on c1.id=t.var_id
for xml explicit

go
-------------------------------------
But this statement:
insert into @t (var_id)
exec ('select id from ' + @table_name)
will not work.

Any tips how can i do it, and how can i pass tables in stored pcedures?

thank you?

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-07-01 : 10:03:59
A temporary table created in stored procedure A is also visible in stored procedure B if A calls B.

Jonathan Boott, MCDBA
Go to Top of Page
   

- Advertisement -