Hi, I want to call a Stored Procedure from an other SP.
SP1 is as follows:
*********************************
CREATE PROCEDURE DetailUpdate
(
@strname char (30),
@id int,
@rv varchar output
)
AS
exec @rv = getstatus @strname,@id
select (@rv)
GO
************************************
CREATE PROCEDURE getstatus
(
@strname char (30),
@id int
)
as
Declare @sql varchar (1000)
select @sql = ('select status from '+@strname+' where id ='+convert(varchar,@id))
exec (@sql)
GO
************************************
This is working in the Query analyzer
***********************************
declare @strname char (30)
declare @id int
declare @SQL VarChar(1000)
set @strname = 'demanddetail'
set @id = 29
select @SQL =('select status from '+@strname+' where id ='+convert(varchar,@id))
exec (@SQL)
**************************************
I just get 'NULL' as a result (not '0') with the SP - the result of the query analyzer is '2'. How do I return the value to the other SP?
This is bothering me now for quite a while and I would be really happy if someone could help me out. Many thanks in advanec!
Just from the Northwind DB -
*********************************
declare @strCompany2Table char (30)
declare @employeeid int
Declare @SQL VarChar(1000)
set @strCompany2Table = 'employees'
set @employeeid= 7
select @SQL =('select extension from '+@strCompany2Table+' where employeeid ='+convert(varchar,@employeeid))
exec (@SQL)
*********************************
SP1 is as follows:
*********************************
CREATE PROCEDURE DetailUpdate
(
@strname char (30),
@id int,
@rv varchar output
)
AS
exec @rv = getstatus @strname,@id
select (@rv)
GO
************************************
CREATE PROCEDURE getstatus
(
@strname char (30),
@id int
)
as
Declare @sql varchar (1000)
select @sql = ('select status from '+@strname+' where id ='+convert(varchar,@id))
exec (@sql)
GO
************************************
This is working in the Query analyzer
***********************************
declare @strname char (30)
declare @id int
declare @SQL VarChar(1000)
set @strname = 'demanddetail'
set @id = 29
select @SQL =('select status from '+@strname+' where id ='+convert(varchar,@id))
exec (@SQL)
**************************************
I just get 'NULL' as a result (not '0') with the SP - the result of the query analyzer is '2'. How do I return the value to the other SP?
This is bothering me now for quite a while and I would be really happy if someone could help me out. Many thanks in advanec!
Just from the Northwind DB -
*********************************
declare @strCompany2Table char (30)
declare @employeeid int
Declare @SQL VarChar(1000)
set @strCompany2Table = 'employees'
set @employeeid= 7
select @SQL =('select extension from '+@strCompany2Table+' where employeeid ='+convert(varchar,@employeeid))
exec (@SQL)
*********************************