False Positive for Find Unused Variables and Parameters

Refactors and formats SQL code.

Moderators: Chris Auckland, David Atkinson, Anu Deshpande, Luke Jefferson

False Positive for Find Unused Variables and Parameters

Postby JMorganSmith » Fri Apr 03, 2009 12:21 am

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 1.3.0.207 and the following code (@LastID) is flagged as an unused variable:

Code: Select all
DECLARE @LastID INT

SET @LastID = @LastID + @@ROWCOUNT

DBCC CHECKIDENT( 'TABLE_NAME_here', RESEED, @LastID)


Thanks
J. Morgan Smith
Senior BI Architect
Teksouth Corporation
JMorganSmith
 
Posts: 1
Joined: Fri Apr 03, 2009 12:07 am

Postby eddie davis » Mon Apr 06, 2009 5: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
Eddie Davis
Technical Support Engineer
Red Gate Software Ltd
E-mail: support@red-gate.com
eddie davis
 
Posts: 943
Joined: Wed Jun 14, 2006 3:47 pm
Location: Red Gate Software


Return to SQL Refactor 1

Who is online

Users browsing this forum: No registered users and 0 guests