False Positive for Find Unused Variables and Parameters

Refactors and formats SQL code.

False Positive for Find Unused Variables and Parameters

Postby JMorganSmith » Thu Apr 02, 2009 11:21 pm

I have seen several examples in these forums of people posting where they received false positives for unused variables, but most of them were using versions previous to v1.3.x

However, I did find one posting regarding table variables where the person was using the latest version.

I have version and the following code (@LastID) is flagged as an unused variable:

Code: Select all

SET @LastID = @LastID + @@ROWCOUNT


J. Morgan Smith
Senior BI Architect
Teksouth Corporation
Posts: 1
Joined: Thu Apr 02, 2009 11:07 pm

Postby eddie davis » Mon Apr 06, 2009 4:34 pm

Thank you for your post into the forum.

Using the code sample, I can recreate the reported fault symptoms.
However when I execute your sample code I get the following error:

Msg 2560, Level 16, State 9, Line 3
Parameter 3 is incorrect for this DBCC statement.

This indicates that the DBCC CHECKIDENT command is valid but does not like the way you have called the third parameter.

I suspect this is the reason why SQL Refactor thinks that your parameter @LastID is unused.

Many Thanks
Eddie Davis
Technical Support Engineer
Red Gate Software Ltd
E-mail: support@red-gate.com
eddie davis
Posts: 1148
Joined: Wed Jun 14, 2006 2:47 pm
Location: Red Gate Software

Return to SQL Refactor Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests