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 2008 Forums
 Transact-SQL (2008)
 Stored procedure output parameter problem

Author  Topic 

KathyTheGreat
Starting Member

1 Post

Posted - 2010-12-13 : 08:20:41
This is probably very simple to fix, but it's got me baffled. Here is the stored procedure and I just need to return one number

ALTER PROCEDURE [dbo].[RDusp_Report_HeatMapHighLikeHighImpact]
-- Add the parameters for the stored procedure here
@SiteID int,
@RiskCount int output,
AS
BEGIN
SET NOCOUNT ON;


-- Insert statements for procedure here

select sum(cnt) as mytotal from
(
select count(Impact.Rating) as cnt from Impact, Likelihood, Exposure where
Impact.SiteID=2
and Exposure.SiteID = 2 and Impact.Rating > 3 and Likelihood.Rating > 3
and Exposure.ImpactID = Impact.ImpactID and exposure.LikelihoodID = Likelihood.LikelihoodID
) as c


END

The value in mytotal I want to return as @RiskCount. But I get errors whenever I try to set @RiskCount = mytotal. Any ideas?

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-12-13 : 08:29:28
Try:
quote:
Originally posted by KathyTheGreat

This is probably very simple to fix, but it's got me baffled. Here is the stored procedure and I just need to return one number

ALTER PROCEDURE [dbo].[RDusp_Report_HeatMapHighLikeHighImpact]
-- Add the parameters for the stored procedure here
@SiteID int,
@RiskCount int output,
AS
BEGIN
SET NOCOUNT ON;


-- Insert statements for procedure here

select @RiskCount = sum(cnt) from
(
select count(Impact.Rating) as cnt from Impact, Likelihood, Exposure where
Impact.SiteID=2
and Exposure.SiteID = 2 and Impact.Rating > 3 and Likelihood.Rating > 3
and Exposure.ImpactID = Impact.ImpactID and exposure.LikelihoodID = Likelihood.LikelihoodID
) as c


END

The value in mytotal I want to return as @RiskCount. But I get errors whenever I try to set @RiskCount = mytotal. Any ideas?

Go to Top of Page
   

- Advertisement -