I'm trying to store a query into a variable and here is what I'm doing :
@check int = [return_code] FROM [dbo].[RESULT] WHERE [code_test] = 'T3005_das'
The return code field only contains the 0 or 1 value. When I'm trying to do this, here's the error message I've got :
Msg 156, Level 15, State 1, Procedure V116_T3005, Line 7
Incorrect syntax near the keyword 'FROM'.
I don't really understand why it's not working properly as I've followed samples of code on the internet.
Any idea?
EDIT : Here's my edited procedure :
CREATE PROCEDURE V116_T3005
DECLARE @check int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT @check = [code_retour] FROM [dbo].[RESULTAT] WHERE [code_test] = 'T3005_das'
--logical code
END
Now I'm getting these errors :
Msg 156, Level 15, State 1, Procedure V116_T3005, Line 7
Incorrect syntax near the keyword 'DECLARE'.Msg 156, Level 15, State 1, Procedure V116_T3005, Line 9
Incorrect syntax near the keyword 'AS'.
SELECTDeclarefrom your Stored Proc. Is@checkyour output variable?