SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Comparing Stored Procedures, Part 6

By Jesse McLain,

This picks up from an earlier article on trying to quantify the comparison of two stored procedures.


For a more complete explanation, please go to my blog entry here. This excerpt from my blog helps to explain what this does:

"Initially using an iterative approach to this problem made a lot of sense, since we need to control the order of the subsequences checked (longer before shorter). There didn't seem to be an obvious way to do this with a CTE. The real power of the CTE comes from its feature of recursion - the ability to have a set of data in the CTE refer to itself (please go here for an excellent article on this). I developed a hybrid approach that would combine iterative and recursive code. The recursive CTE in it will select off the longest matching subsequence between the two sequences it can find whose values are all unmatched, save it in a temp table, and then update the two sequences to show the matching values. It would then continue doing this until no more matching subsequences can be found."

Written by Jesse McLain




Total article views: 1385 | Views in the last 30 days: 2
Related Articles

Matching Subsequences

In an effort to compare the text of two stored procedures, I generalized the problem and created cod...


Remove Pattern Matched Characters

Remove characters matched in a patindex pattern recursively.


Recursive Trigger not Firing.

Instead of Trigger not firing a subsequent trigger recursively


Recursive Query

Recursive Query


Recursive CTE calculations

Reusing the previous value of a recursive CTE to construct the new value