Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Table Alias & CTE Naming Conflict in MERGE (Exam 70-461)

$
0
0

The following T-SQL segment is from Exam 70-461 Training Kit, "Using the MERGE statement" (page 392 - may not be correct):

WITH SRC AS( SELECT * FROM Sales.Orders WHERE ShipCountry = N'Norway' ) MERGE INTO Sales.MyOrders AS TGT USING Sales.Order AS SRC ON SRC.OrderID = TGT.OrderID

WHEN MATCHED AND ( TGT.CustID <> SRC.CustID

....) THEN UPDATE

SET TGT.CustID = SRC.CustID ......

WHEN NOT MATCHED THEN INSERT

VALUES (SRC.OrderID,.....)

I find very confusing that the CTE is named "SRC"  and the table alias also for the MERGE source.

I would not use confusing names/aliases in production code or in training books.

Am I mistaken? Am I missing something? Thanks.


Kalman Toth Database & OLAP Architect sqlusa.com
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012





Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>