mardi 24 mars 2015

How to report on stored procedures without unit tests

Our SQL project has a huge number of stored procedures that should all be accompanied by a unit test.


I'm trying to write some Powershell to report on stored procedures that aren't accompanied by a unit test.


Finding the list of stored procedures is trivial - checking they have a test, not so simple. The code seems to be stored in resource files.


This is what I have so far:



$sps = ((gci -recurse -include *.sql | select-string "CREATE PROCEDURE") -split ':' | select-string "CREATE PROCEDURE" | ForEach-Object {$_ -Replace "CREATE PROCEDURE ", ""}) -split " " | select-string "\."

foreach ($sp in $sps)
{

Write-Host $sp

#ToDo: For each stored procedure, report on a count of EXEC statements calling this procedure in .resx files

}


Any suggestions?


Aucun commentaire:

Enregistrer un commentaire