Download the Thanksgiving query sample code here.
I thought it would be fun to put together a query to get us in the spirit of Thanksgiving dinner tonight.
This query is using techniques from another recent posting on CSV formatting query output.
Here is my Thanksgiving gift to you, the Thanksgiving day query.
Don’t copy and paste, your browser may mess up the single quotes… Instead download the Thanksgiving query sample code here.
-- a fun Thanksgiving day sql query
SELECT 'turkey'
UNION
SELECT 'stuffing'
UNION
SELECT 'cranberry sauce'
UNION
SELECT 'yams'
UNION
SELECT 'sweet potato pie'
UNION
SELECT 'gravy'
UNION
SELECT 'beans'
UNION
SELECT 'green bean casserole'
UNION
SELECT 'mashed potatos'
UNION
SELECT 'collard greens'
UNION
SELECT 'beer'
UNION
SELECT 'cider'
UNION
SELECT 'pumpkin pie';GO
-- but thats too much food,
--so lets keep on the diet track with only 5 items for turkey day dinnerSELECT TOP 5 fooditem FROM (
SELECT 'turkey' AS fooditem
UNION
SELECT 'stuffing'
UNION
SELECT 'cranberry sauce'
UNION
SELECT 'yams'
UNION
SELECT 'sweet potato pie'
UNION
SELECT 'gravy'
UNION
SELECT 'beans'
UNION
SELECT 'green bean casserole'
UNION
SELECT 'mashed potatos'
UNION
SELECT 'collard greens'
UNION
SELECT 'beer'
UNION
SELECT 'cider'
UNION
SELECT 'pumpkin pie' ) AS t1
ORDER BY Newid(); -- throw in some random orderingGO
-- ok, but lets throw it into a comma delimited list rather than a tableSELECT Substring((SELECT ', ' + fooditem
FROM (
SELECT TOP 5 fooditem FROM (
SELECT 'turkey' AS fooditem
UNION
SELECT 'stuffing'
UNION
SELECT 'cranberry sauce'
UNION
SELECT 'yams'
UNION
SELECT 'sweet potato pie'
UNION
SELECT 'gravy'
UNION
SELECT 'beans'
UNION
SELECT 'green bean casserole'
UNION
SELECT 'mashed potatos'
UNION
SELECT 'collard greens'
UNION
SELECT 'beer'
UNION
SELECT 'cider'
UNION
SELECT 'pumpkin pie' ) AS t1 ORDER BY Newid()) AS t2
FOR XML PATH('')),3,10000000) AS list
Happy Thanksgiving Everyone!
More from Stedman Solutions:
Steve and the team at Stedman Solutions are here for all your SQL Server needs.
Contact us today for your free 30 minute consultation..
We are ready to help!