Created
December 9, 2025 15:42
-
-
Save danielleevandenbosch/88dc63a5bfb6e1943a28805535fe67e0 to your computer and use it in GitHub Desktop.
Halo CE Lorum Ipsum table generator for MS-SQL Server
This file contains hidden or 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
| -- Ensure schema exists | |
| IF NOT EXISTS (SELECT 1 FROM sys.schemas WHERE name = 'internalsys') | |
| EXEC('CREATE SCHEMA internalsys'); | |
| -- Drop table if it exists | |
| IF OBJECT_ID('internalsys.LoremIpsum', 'U') IS NOT NULL | |
| DROP TABLE internalsys.LoremIpsum; | |
| CREATE TABLE internalsys.LoremIpsum | |
| ( | |
| Id UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID() | |
| , RowNum INT NOT NULL | |
| , Title NVARCHAR(200) NOT NULL | |
| , BodyText NVARCHAR(MAX) NOT NULL | |
| , CreatedAt DATETIME2 NOT NULL DEFAULT SYSDATETIME() | |
| , CONSTRAINT PK_LoremIpsum PRIMARY KEY (Id) | |
| ); | |
| ------------------------------------------------------------ | |
| -- Word bank (Lorem + HALO CE Easter eggs) | |
| ------------------------------------------------------------ | |
| DECLARE @Words TABLE (w NVARCHAR(40)); | |
| INSERT INTO @Words (w) | |
| VALUES | |
| ('lorem'),('ipsum'),('dolor'),('sit'),('amet'),('consectetur') | |
| , ('adipiscing'),('elit'),('sed'),('do'),('eiusmod'),('tempor') | |
| , ('incididunt'),('labore'),('magna'),('aliqua'),('veniam') | |
| , ('quis'),('nostrud'),('commodo'),('exercitation'),('ullamco') | |
| , ('fugiat'),('pariatur'),('excepteur'),('cupidatat'),('proident') | |
| , ('anim'),('laborum'),('deserunt'),('amet'),('dolore') | |
| -- Halo CE seasoning | |
| , ('Master Chief'),('Covenant'),('Warthog'),('Needler') | |
| , ('Plasma'),('Arbiter'),('Elite'),('Flood'),('Halo') | |
| , ('Ringworld'),('UNSC'),('Spartan'),('Mjolnir'),('Grunt') | |
| , ('Banshee'),('Pelican'),('Energy Sword'); | |
| ------------------------------------------------------------ | |
| -- Random punctuation bits | |
| ------------------------------------------------------------ | |
| DECLARE @P TABLE (p NVARCHAR(2)); | |
| INSERT INTO @P (p) | |
| VALUES ('.'),(','),('!'),('?'); | |
| ------------------------------------------------------------ | |
| -- 200 rows, each row generated independently & uniquely | |
| ------------------------------------------------------------ | |
| ;WITH | |
| Nums AS | |
| ( | |
| SELECT TOP (200) | |
| ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS n | |
| FROM sys.all_objects a | |
| CROSS JOIN sys.all_objects b | |
| ) | |
| INSERT INTO internalsys.LoremIpsum | |
| ( | |
| RowNum | |
| , Title | |
| , BodyText | |
| ) | |
| SELECT | |
| N.n | |
| , RTRIM(T.TitleText) | |
| , 'Lorum ipsum. ' + RTRIM(B.BodyChunk) | |
| FROM Nums AS N | |
| -------------------------------------------------------- | |
| -- Random title per row (4 words, order depends on N.n) | |
| -------------------------------------------------------- | |
| CROSS APPLY | |
| ( | |
| SELECT | |
| ( | |
| SELECT TOP (4) | |
| w.w + ' ' | |
| FROM @Words AS w | |
| ORDER BY CHECKSUM(NEWID(), N.n, w.w) -- per-row, per-word random | |
| FOR XML PATH(''), TYPE | |
| ).value('.', 'nvarchar(200)') AS TitleText | |
| ) AS T | |
| -------------------------------------------------------- | |
| -- Random body per row (~50 words, with punctuation) | |
| -------------------------------------------------------- | |
| CROSS APPLY | |
| ( | |
| SELECT | |
| ( | |
| SELECT TOP (50) | |
| w.w | |
| + CASE | |
| WHEN ABS(CHECKSUM(NEWID(), N.n, w.w)) % 100 < 15 | |
| THEN ( | |
| SELECT TOP (1) p.p | |
| FROM @P AS p | |
| ORDER BY CHECKSUM(NEWID(), N.n, w.w, p.p) | |
| ) | |
| ELSE ' ' | |
| END + ' ' | |
| FROM @Words AS w | |
| ORDER BY CHECKSUM(NEWID(), N.n, w.w, 'body') -- per-row shuffle | |
| FOR XML PATH(''), TYPE | |
| ).value('.', 'nvarchar(max)') AS BodyChunk | |
| ) AS B; | |
| SELECT COUNT(*) AS InsertedRows | |
| FROM internalsys.LoremIpsum; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment