Skip to content

Instantly share code, notes, and snippets.

@erikdarlingdata
Created April 10, 2026 21:07
Show Gist options
  • Select an option

  • Save erikdarlingdata/20df5b8604d3673f474de798120a891f to your computer and use it in GitHub Desktop.

Select an option

Save erikdarlingdata/20df5b8604d3673f474de798120a891f to your computer and use it in GitHub Desktop.
-- Hot Dog in a Bun - SQL Server Geometry Art
-- Run in SSMS and click "Spatial results" tab to view the masterpiece
DECLARE @bun geometry;
DECLARE @sausage geometry;
DECLARE @mustard geometry;
DECLARE @relish geometry;
-- Bun: wide capsule shape with a V-notch cut from the top
SET @bun = geometry::STGeomFromText('LINESTRING(2 0, 18 0)', 0).STBuffer(3.5)
.STDifference(
geometry::STGeomFromText(
'POLYGON((0 0.3, 10 2.8, 20 0.3, 20 0.8, 10 3.2, 0 0.8, 0 0.3))', 0
)
);
-- Sausage: narrower capsule, poking out both ends of the bun
SET @sausage = geometry::STGeomFromText('LINESTRING(0.8 0.8, 19.2 0.8)', 0)
.STBuffer(1.4);
-- Mustard: zigzag drizzle across the top
SET @mustard = geometry::STGeomFromText(
'LINESTRING(3 1, 4 2.3, 5 1, 6 2.3, 7 1, 8 2.3, 9 1, 10 2.3, 11 1, 12 2.3, 13 1, 14 2.3, 15 1, 16 2.3, 17 1)', 0
).STBuffer(0.18);
-- Relish: little dollops scattered on top
SET @relish = geometry::STGeomFromText('POINT(4.5 1.5)', 0).STBuffer(0.28)
.STUnion(geometry::STGeomFromText('POINT(6.5 0.5)', 0).STBuffer(0.24))
.STUnion(geometry::STGeomFromText('POINT(8.8 1.6)', 0).STBuffer(0.26))
.STUnion(geometry::STGeomFromText('POINT(11.2 0.6)', 0).STBuffer(0.22))
.STUnion(geometry::STGeomFromText('POINT(13.5 1.4)', 0).STBuffer(0.28))
.STUnion(geometry::STGeomFromText('POINT(15.5 0.7)', 0).STBuffer(0.25));
-- Output for SSMS Spatial Results tab (shows each component as a layer)
SELECT @bun AS shape, 'Bun' AS label, 1 AS draw_order
UNION ALL
SELECT @sausage, 'Sausage', 2
UNION ALL
SELECT @mustard, 'Mustard', 3
UNION ALL
SELECT @relish, 'Relish', 4
ORDER BY draw_order;
-- Also output WKT for text verification
SELECT 'Bun' AS part, @bun.STAsText() AS wkt, @bun.STNumPoints() AS points
UNION ALL
SELECT 'Sausage', @sausage.STAsText(), @sausage.STNumPoints()
UNION ALL
SELECT 'Mustard', @mustard.STAsText(), @mustard.STNumPoints()
UNION ALL
SELECT 'Relish', @relish.STAsText(), @relish.STNumPoints();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment