December 18, 2009 at 1:32 pm
What do people think of the With and CTE. I recently received code that looked like this and it seemed like over-kill.
(SELECT [SWL_ID], [SWL_it] FROM [excelleRx_DBA].[dbo].[T_TEST_SWL] where [SWL_ID] > '3')
DELETE f
FROM [excelleRx_DBA].[dbo].[T_TEST_SWL] f
INNER JOIN RecordsToDelete r ON r.[SWL_ID] = f.[SWL_ID]
Instead of
DELETE f
FROM [excelleRx_DBA].[dbo].[T_TEST_SWL] f
Where [SWL_ID] > '3'
Just wanting to hear the pros and cons of it.
Thanks for any information
steve
December 18, 2009 at 1:38 pm
Properly used CTE's are well worth considering. They can help with the development of complex queries, and if you have section of code that would use the same query in a drived table, it makes it easier to accomplish as you only have to define it once.
What you should, which looked incomplete as I was confused when I first looked at it, seems to demonstrate that it can also be used inappropriately.
December 23, 2009 at 6:39 pm
Some people don't know how to write queries, or use there limited knowledge to complete a task (likely cause in this scenario).
I like to look at CTE's at temporary views. They are awesome when used properly. You can even use multiple CTE's.
Try: Delete excelleRx_DBA.dbo.T_TEST_SWL Where SWL_ID > 3
December 24, 2009 at 2:09 am
This was removed by the editor as SPAM
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply