Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Continuous dates, cant see how to avoid cursor!

Author  Topic 

Teroman
Posting Yak Master

115 Posts

Posted - 2001-08-28 : 10:32:40
I think this is pretty tricky, but am ready to be proven wrong.

I have a table of problems, which have an id, start and end dates, stored as whole days, no time. Also a bunch of other stuff, but nothing significant.

When data enters the system a bunch of procs decide on what days there are problems in the data.
These problems are held in a different table and have only a date on them, ie they are for 1 day.

Data can be missing and come in late, and we get no file over the weekend, just a 3 day file on monday.

Late data may fix existing problems.

What i want to do is write a proc that will extend any existing problems if the problem is contiguous (ie no day gaps in the sequence), and add new problems to the table if there is a gap.

Also late data may require me to make new problems in the past, as we check 28 days into the past for new problems.

Set based SQL seems to be pretty poor at doing this kind of thing.

Obviously with a cursor you can go round and do updates + inserts as you see fit, but as I just voted cursors as my most hated SQL tool id feel pretty silly turning to them 5 mins later.

Any ideas gratefully recieved, if anything isnt clear then just ask/flame me depending on how well your day is going.

col

   

- Advertisement -