Answer for:

TSQL If/When issue

Message 7 of 8

View entire thread
0 Votes
Tony Hopkinson

only recomend them when your sql get's to teh unmaintainable and incomprehensible stage.

Both will get round the structural difficulties

Temporary tables break the job down in to bits, create a table(s) to hold imtermediate stages and then use them as input to teh next stage.

The big advantage is yopu can see the intermediate results as you develop the code, usually various shortcuts suggest themselves as well. Not a good idea with huge amounts of data though, as the engine will be limited in terms of optimisation.

The trigger manouver might be more suitable for you

Basically you create a table to hold review date and end date. Then use trigger on your current table to in insert/updates of a review add / update a record. On end to find the right one and then update that.

Don't go mad with triggers though, remember they are part of the original transaction.