Question:Analyze the following code used to update a Common Table Expression:
USE demodb
GO
DECLARE @a TABLE (ID int, Value int);
DECLARE @b TABLE (ID int, Value int);
INSERT @a VALUES (1, 10), (2, 20);
INSERT @b VALUES (1, 100),(2, 200);
WITH cte AS (SELECT * FROM @a)
UPDATE cte
SET Value = b.Value
FROM cte AS a
INNER JOIN @b AS b ON b.ID = a.ID
SELECT * FROM @a
GO
What Will be the output of the above code? 

A ID Value ----- ----- 1 100 2 200 

B ID Value ----- ----- 1 10 2 100 

C ID Value ----- ----- 1 10 2 200 

D ID Value ----- ----- 1 100 2 100 

+ Answer
+ Report
Total Preview: 492

Copyright © 2024. Powered by Intellect Software Ltd