Hi, I have a stored procedure in T-Sql with this code at the end of it:
UPDATE @Results
SET Percentage = CASE B.Total
WHEN 0 THEN 0
ELSE (CAST(Number AS FLOAT)/B.Total)
END
FROM @TotalAnswersPerQuestion AS B
WHERE @Results.QuestionNumber=B.QuestionNumber
The temp table @Results is defined and correctly used in this store procedure just before these instructions, but I get an error on the last line saying:
Msg 137, Level 15, State 2, Procedure Report, Line 111 Must declare the scalar variable "@Results".
This are my tables:
DECLARE @TotalAnswersPerQuestion Table
(QuestionNumber int,
Total int)
DECLARE @Results Table
(
QuestionNumber int,
QuestionTitle varchar(max),
AnswerNumber int,
AnswerLable varchar(max),
ProfileGroupID int,
[Name] varchar(255),
Identifier varchar(20),
Number int,
Percentage float
)
What's wrong?