I am just learning the sql. I have this query and trying to optimize the query rewriting.Please help me out more efficient way of writing this query--Thanks!!
DECLARE @Test TABLE ( ID INT ,DetailID INT , PrevID INT );
INSERT INTO @Test ( ID , DetailID ,SaleID)
UPDATE tblc SET Flag = 'y'
WHERE id IN ( SELECT ID FROM @Test UNION ALL SELECT PrevID FROM @Test );