Microsoft Fabric Data Engineer Associate DP-700 Practice Question
A stored procedure in a Microsoft Fabric warehouse runs this statement to upsert rows from StgSales into DimCustomer:
MERGE dbo.DimCustomer AS tgt
USING dbo.StgSales AS src
ON tgt.CustomerID = src.CustomerID
WHEN MATCHED THEN
UPDATE SET tgt.City = src.City, tgt.Region = src.Region
WHEN NOT MATCHED BY TARGET THEN
INSERT (CustomerID, City, Region)
VALUES (src.CustomerID, src.City, src.Region);
Execution fails with the error: "The MERGE statement attempted to UPDATE or DELETE the same row more than once. A target row matched more than one source row." You must correct the T-SQL so the procedure succeeds while still performing the required updates and inserts.
Which change should you make to the statement?
Add the table hint WITH (NOLOCK) to dbo.StgSales in the USING clause.
Rewrite the USING clause to select DISTINCT CustomerID, City, Region from dbo.StgSales before the MERGE is executed.
Execute SET IDENTITY_INSERT dbo.DimCustomer ON immediately before running the MERGE.
Replace the MERGE with an INSERT statement that uses the ON ERROR clause to ignore conflicts.
The error appears because more than one row in the source can match a single row in the target on CustomerID, so the MERGE would update the same target row multiple times. Selecting only one row per CustomerID in the source eliminates the conflict. Adding DISTINCT (or similar deduplication logic) in the USING clause guarantees each target row can match at most one source row, allowing the MERGE to complete. Using WITH (NOLOCK) can change the set of rows returned and does not guarantee removal of duplicates; SET IDENTITY_INSERT affects identity columns and is unrelated to this error; and INSERT … ON ERROR is not valid T-SQL syntax.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is a MERGE statement in T-SQL?
Open an interactive chat with Bash
Why does adding DISTINCT resolve the error?
Open an interactive chat with Bash
How does WITH (NOLOCK) affect the query in T-SQL?
Open an interactive chat with Bash
Microsoft Fabric Data Engineer Associate DP-700
Monitor and optimize an analytics solution
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .