How about good morning I try to print the value of a variable inside an exec () depending on an if but I mark syntax errors.
DECLARE @VALOR1 INT
SET @VALOR1 = 1
EXEC ('
IF ('+@VALOR1+' = 1)
print '+@VALOR1+'
ELSE
SET '+@VALOR1+' = 2
print '+@VALOR1+'
END ')
could someone help me? Thank you! PD (the assignment of value1 to 2 is only to see what enters the else.