Last active
July 31, 2021 18:04
-
-
Save erikdarlingdata/b9744f72f86e4f7bd7c2c0d47821cfdf 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
SELECT | |
n = 1, | |
query = | |
N'SELECT records = COUNT_BIG(*) | |
FROM dbo.Posts AS p1' | |
UNION ALL | |
SELECT | |
n = 2147483648, | |
N'OPTION(MERGE JOIN, FORCE ORDER, MAXDOP 2);' | |
UNION ALL | |
SELECT | |
n = x.n, | |
N'JOIN dbo.Posts AS p' + | |
RTRIM(x.n) + | |
N' ON p' + | |
RTRIM(x.n - 1) + | |
N'.ParentId = p' + | |
RTRIM(x.n) + | |
N'.ParentId' | |
FROM | |
( | |
SELECT | |
ROW_NUMBER() OVER | |
( | |
ORDER BY | |
1/0 | |
) AS n | |
FROM sys.messages AS m | |
)AS x | |
WHERE x.n > 1 | |
AND x.n <= 317 | |
ORDER BY n; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment