The variable declared here is used before it has a value ...

dim_rutdim_rut Posts: 2
edited January 27, 2007 6:51AM in SQL Refactor Previous Versions
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" ...

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hello,

    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.
Sign In or Register to comment.