Relative Content

Tag Archive for sqlsql-serverdatabase-cursor

How to get rid of CURSOR if every FETCH needs a SELECT based on previous result

We have a couple of tables, let’s call them Sections and SectionTimeWindows. Sections table contains data about sections of ‘movement’, which starts at a place, ends at a place and has a type. The type is important, because it determines how much time will a section take – every section type has a set of time windows and the window determines the running time of a section based on when we arrive at the section.

SQL Stored procedure keeps going in infinite loop

When i execute my stored procedure it will keep going in an infinite loop when i only want it to iter through it once, and i cant seem to understand why. I Sucessfully inserts correct number of records into my PartitionInfo but when i use cursor to iter through it it will keep going until i get Msg 217, Level 16, State 1, Procedure ConnectorFile.GetPartitionInfo, Line 85 [Batch Start Line 84] Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).