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
 Transact-SQL (2000)
 Parameter return in a execute

Author  Topic 

pap
Starting Member

13 Posts

Posted - 2004-03-03 : 06:14:54
Hello,

How can I pass the value of the count(*) to outside the execute. I need the value to continue with the sp

set @sql= 'declare @res int select @res=count(*) from t
where tam=(select '+@posxx+' from sffpoxx0 where ponbr='+@Col001+' and poodn='+@Col002+' and pocat='+@Col007+')'

???????? set @result=exec (@sql) ????????????? Something like this


Thanks
Paulo

nr
SQLTeam MVY

12543 Posts

Posted - 2004-03-03 : 06:39:33
declare @cnt int
declare @sql nvarchar(1000)
select @sql = 'select @cnt = count(*) from ...'

exec sp_executesql @sql, N'@cnt int out', @cnt out



==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-03-03 : 06:40:05
This can be done if the procedure is using output parameters:

--*************************************************
create procedure testdd @brncode INT,
@Res varchar(50) output
as
set @res = (select branchdesc from branch where branchcode = @brncode)


--THEN you populate the variable like this:


declare @branchdesc varchar(50)

exec testdd 2701, @branchdesc output

select @branchdesc


Duane.
Go to Top of Page
   

- Advertisement -