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.
| 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 spset @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 ThanksPaulo |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-03-03 : 06:39:33
|
| declare @cnt intdeclare @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. |
 |
|
|
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) outputas set @res = (select branchdesc from branch where branchcode = @brncode)--THEN you populate the variable like this:declare @branchdesc varchar(50)exec testdd 2701, @branchdesc outputselect @branchdescDuane. |
 |
|
|
|
|
|