PUZZLE1 – What is the output of the below query NEWID

What is the output of the following query:
DECLARE @TEMPNEWID TABLE (iden int identity(1,1),COL1 int,COL2 UNIQUEIDENTIFIER)

INSERT INTO @TEMPNEWID(COL1,COL2)
SELECT 1,NEWID()
UNION
SELECT 2,NEWID()
UNION
SELECT 3,NEWID()
UNION
SELECT 4,NEWID()
UNION
SELECT 5,NEWID()
UNION
SELECT 6,NEWID()
UNION
SELECT 7,NEWID()
UNION
SELECT 8,NEWID()
UNION
SELECT 9,NEWID()
UNION
SELECT 10,NEWID()
UNION
SELECT 11,NEWID()
UNION
SELECT 12,NEWID()

DELETE T FROM
@tempnewid AS T
INNER JOIN (SELECT TOP 3 iden FROM
@tempnewid ORDER BY NEWID() ) as T1
ON T.iden = T1.iden

SELECT COUNT(*) FROM @tempnewid

How many records will be deleted from table variable @tempnewid?
What will be the output of count(*)?

Leave a Reply

Your email address will not be published. Required fields are marked *