May 13, 2010 at 4:59 pm
I got a question wrong in the practice test. I'm pretty sure this type of format is not allowed. Am I way off here, is this some obscure t-sql coding practice that I'm not aware of?
The correct statement is
DELETE FROM Products AS P1 FROM NewProducts AS P2 WHERE P1.id = P2.id
The FROM statement is used in a DELETE statement to indicate a table join.
Or is it likely a typo?
Thanks for the sanity check.
Keith Wiggans
May 13, 2010 at 5:03 pm
It's close. It should be:
DELETE FROM Products FROM Products AS P1 JOIN NewProducts AS P2 ON P1.id = P2.id
Note that the first FROM is optional, so it also could be:
DELETE Products FROM Products AS P1 JOIN NewProducts AS P2 ON P1.id = P2.id
Edit: See the DELETE statement in BOL for detailed information.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 14, 2010 at 4:20 am
Right, there is no FROM FROM.
Just wanted to bounce that off of somebody.
The practice exam is full of weird little errors like that.
Thanks 😀
Keith Wiggans
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply