Code Analysis/Code Guard: "The value assigned here is never used"

I've installed SQLPrompt 9, and SQL Code Guard, the latter to be able to run a summary across a database, as SQLPrompt doesn't have that ability yet. I use SSMS 16 when using Code Guard, and SSMS 17 otherwise.

I noticed that in one stored procedure in SSMS 16 I get a warning "The value assigned here is never used" for a variable that is declared with a value assignment and then later is updated with something like SET @var = ISNULL(<blah>, @var).

This is of course an awesome feature, but unfortunately it doesn't work in SSMS 17, nor can I get a repro working in SSMS 16. In SSMS 17, a variable will be flagged under rule MI005 even if the variable gets assigned a value in a simple scenario later (but not in more complicated scenarios like SET @var = ISNULL(<blah>, @var)), however, only the variable declaration is flagged, but not the unused value assignments later.

So
1) Can we have the lines that assign values to unused variables flagged as well? Obviously Code Analysis can work out which lines those are.
2) Is the more extended version of the rule that exists in Code Guard going to show up in Code Analysis eventually?
3) Is this functionality also going to be extended to table variables? At the moment they are considered "used" as soon as data is inserted in them, even if that is the only thing that happens to them.
Sign In or Register to comment.