{"id":26,"date":"2011-06-30T08:19:05","date_gmt":"2011-06-30T08:19:05","guid":{"rendered":"https:\/\/sqlserverlearner.azurewebsites.net\/2011\/06\/30\/puzzle1-what-is-the-output-of-the-below-query-newid\/"},"modified":"2011-06-30T08:19:05","modified_gmt":"2011-06-30T08:19:05","slug":"puzzle1-what-is-the-output-of-the-below-query-newid","status":"publish","type":"post","link":"https:\/\/sqlserverlearner.com\/2011\/06\/30\/puzzle1-what-is-the-output-of-the-below-query-newid\/","title":{"rendered":"PUZZLE1 – What is the output of the below query NEWID"},"content":{"rendered":"

What is the output of the following query:
\nDECLARE @TEMPNEWID TABLE (iden int identity(1,1),COL1 int,COL2 UNIQUEIDENTIFIER)<\/p>\n

INSERT INTO @TEMPNEWID(COL1,COL2)
\nSELECT 1,NEWID()
\nUNION
\nSELECT 2,NEWID()
\nUNION
\nSELECT 3,NEWID()
\nUNION
\nSELECT 4,NEWID()
\nUNION
\nSELECT 5,NEWID()
\nUNION
\nSELECT 6,NEWID()
\nUNION
\nSELECT 7,NEWID()
\nUNION
\nSELECT 8,NEWID()
\nUNION
\nSELECT 9,NEWID()
\nUNION
\nSELECT 10,NEWID()
\nUNION
\nSELECT 11,NEWID()
\nUNION
\nSELECT 12,NEWID()<\/p>\n

DELETE T FROM
\n@tempnewid AS T
\nINNER JOIN (SELECT TOP 3 iden FROM
\n @tempnewid ORDER BY NEWID() ) as T1
\nON T.iden = T1.iden <\/p>\n

SELECT COUNT(*) FROM @tempnewid<\/code><\/p>\n

How many records will be deleted from table variable @tempnewid?
\nWhat will be the output of count(*)?<\/p>\n","protected":false},"excerpt":{"rendered":"

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…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[88],"tags":[],"_links":{"self":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/26"}],"collection":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":0,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}