I would like to assign the value of the local variable within SELECT
, as in the example below, but it displays the following error message:
"A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations."
CREATE PROCEDURE [dbo].[TESTE]
@Param INT
AS
BEGIN
SET NOCOUNT ON;
DECLARE @VariavelLocal DECIMAL,@VariavelLocal2 DECIMAL
SELECT (@VariavelLocal1 = SELECT COUNT(TesteId) FROM Table)
,(@VariavelLocal2 = 1)
,@VariavelLocal1 + @VariavelLocal2
,T2.T2Teste
FROM Table2 T2
END
Can you do this?