finding unused variables in Stored Procedures

  • I've got a couple of hundred stored procedures that have been amended by various developers over the years. There appear to be many with variables declared that are not actually used. Does anyone know of a quick way of identifying these?

  • Intriguing question.

    Sorry though, no help. Will try find a way though.

    Crispin

    Why don't you try practicing random acts of intelligence and senseless acts of self-control?

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • The only thing I can think of is writing a RegEx to run against the script. Would be beyond my regex capability, but I am sure it could be done. Or you could write some custom search code.

    Tim C.

    //Will write code for food


    Tim C //Will code for food

  • Beyond me as well. Trying brute force, you could grab the script for each proc, then iterate through and comment out one line containing a declare, then try to run the alter. If it fails, uncomment, otherwise leave it alone. Even as a force technique I think it would go pretty quickly.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply