MCQs > IT & Programming > Microsoft SQL Server > 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?

Microsoft SQL Server MCQs

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?

Answer

Correct Answer: ID Value ----- ----- 1 100 2 200

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Microsoft SQL Server Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Microsoft SQL Server Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it