Wednesday, March 7, 2012

returning temp tables, t-sql stored procedures

Hi, im a bit of a beginner here and need to know how to call stored procedures from another sp and how can I return a temp table that I need to use in the calling sp's where clause?
Some code would b great.
CheersAre you looking for something like this?

create proc proc2
as
insert #tmp
select 1,'Q'
go
create proc proc1
as
create table #tmp(id int, code varchar(10))
exec proc2
select * from #tmp
go
exec proc1

or

alter proc proc2
as
select 1,'Q'
go
alter proc proc1
as
create table #tmp(id int, code varchar(10))
insert #tmp
exec proc2
select * from #tmp
go
exec proc1

or ?|||cheers thats all that is required

No comments:

Post a Comment