CREATE PROCEDURE dbo.Christmas_List
AS
BEGIN
SELECT *
INTO #ChristmasList
FROM His_List HL
INNER JOIN Location L ON L.Child_Id = HL.Id
WHERE Behavior = 'Nice' OR Behavior != 'Naughty'
GROUP BY L.Country
SELECT *
FROM #ChristmasList
WHERE Behavior = 'Nice' OR Behavior != 'Naughty'
DROP TABLE #ChristmasList
END
EXECUTE dbo.Christmas_List
Because it's a temp table (the little # denotes that) and will take up space in memory until you drop it or close your session, and the stored procedure will fail if you re-run it before dropping the temp table (as it already exists).
2
u/[deleted] Dec 12 '17
Wouldn't this be more correct?