The objective is to find circular references in a single table related to itself. The script deals with a sample table Skills that have a SkilGUID (primary key) field and a SkilParentGUID field which is a foreign key to the record's parent from the same table. The number of levels in the hierarchy is not limited. Of course, the highest object in a hierarchy will have NULL in ParentGUID field. Here the datatype for GUIDs is uniqueidentifier but it may as well be an int or whatever.
The script is rather straightforward and simple - it just returns the GUIDs engaged in circular references. Of course it may be enhanced in many possible ways.
Like the one posted before, the use of the SP is like this: proc_alerts 1,18. This will show the first 18 alerts on the system. OR proc_alerts 20,35 will show from 20 to 35. This lets you manage the list without letting go out of the screen.