-
-
Save erikdarlingdata/8405594f3b651576a46a9a7885c78bde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE #ts | |
( | |
Id int NOT NULL, | |
--Id int NOT NULL INDEX c CLUSTERED (Id), | |
--Id int NOT NULL PRIMARY KEY, | |
--Id int IDENTITY, /*If you use this one, also comment out the Id column in the select*/ | |
AcceptedAnswerId int NULL, | |
AnswerCount int NULL, | |
ClosedDate datetime NULL, | |
CommentCount int NULL, | |
CommunityOwnedDate datetime NULL, | |
CreationDate datetime NOT NULL, | |
FavoriteCount int NULL, | |
LastActivityDate datetime NOT NULL, | |
LastEditDate datetime NULL, | |
LastEditorDisplayName nvarchar(40) NULL, | |
LastEditorUserId int NULL, | |
OwnerUserId int NULL, | |
Score int NOT NULL, | |
Tags nvarchar(150) NULL, | |
Title nvarchar(250) NULL, | |
ViewCount int NOT NULL | |
); | |
INSERT #ts | |
SELECT | |
p.Id, | |
p.AcceptedAnswerId, | |
p.AnswerCount, | |
p.ClosedDate, | |
p.CommentCount, | |
p.CommunityOwnedDate, | |
p.CreationDate, | |
p.FavoriteCount, | |
p.LastActivityDate, | |
p.LastEditDate, | |
p.LastEditorDisplayName, | |
p.LastEditorUserId, | |
p.OwnerUserId, | |
p.Score, | |
p.Tags, | |
p.Title, | |
p.ViewCount | |
FROM dbo.Posts AS p | |
WHERE p.Score > 5 | |
AND p.PostTypeId = 1; | |
DROP TABLE #ts; | |
GO | |
CREATE TABLE #tp | |
( | |
Id int NOT NULL, | |
AcceptedAnswerId int NULL, | |
AnswerCount int NULL, | |
ClosedDate datetime NULL, | |
CommentCount int NULL, | |
CommunityOwnedDate datetime NULL, | |
CreationDate datetime NOT NULL, | |
FavoriteCount int NULL, | |
LastActivityDate datetime NOT NULL, | |
LastEditDate datetime NULL, | |
LastEditorDisplayName nvarchar(40) NULL, | |
LastEditorUserId int NULL, | |
OwnerUserId int NULL, | |
Score int NOT NULL, | |
Tags nvarchar(150) NULL, | |
Title nvarchar(250) NULL, | |
ViewCount int NOT NULL | |
); | |
INSERT #tp WITH(TABLOCK) | |
SELECT | |
p.Id, | |
p.AcceptedAnswerId, | |
p.AnswerCount, | |
p.ClosedDate, | |
p.CommentCount, | |
p.CommunityOwnedDate, | |
p.CreationDate, | |
p.FavoriteCount, | |
p.LastActivityDate, | |
p.LastEditDate, | |
p.LastEditorDisplayName, | |
p.LastEditorUserId, | |
p.OwnerUserId, | |
p.Score, | |
p.Tags, | |
p.Title, | |
p.ViewCount | |
FROM dbo.Posts AS p | |
WHERE p.Score > 5 | |
AND p.PostTypeId = 1 | |
OPTION(MAXDOP 12); | |
DROP TABLE #tp; | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment