The variable declared here is used before it has a value ...
dim_rut
Posts: 2
Consider simple SQL:
DECLARE @retVal INT
EXEC @retVal = [dbo].[MyTest]
IF @retVal < 0 BEGIN
SELECT -111
END
It looks completety legal, but when running SQL Refactor -> Find unused variables it underlines '@retVal' and shows error message "The variable declared here is used before it has a value assigned to it" ...
DECLARE @retVal INT
EXEC @retVal = [dbo].[MyTest]
IF @retVal < 0 BEGIN
SELECT -111
END
It looks completety legal, but when running SQL Refactor -> Find unused variables it underlines '@retVal' and shows error message "The variable declared here is used before it has a value assigned to it" ...
Comments
I'm aware that Refactor needs some work in the 'find undefined variables' area, and I'm sure that we are working on a fix for this already. I recall seeing this one during the beta; SET @MyVar='123' and SELECT @MyVar='123' will work, but certain things like getting the value from a stored procedure or UDF seem to be an issue still.