Ho riscritto la procedura memorizzata come:
SET NOCOUNT ON
SELECT SUM(CASE WHEN DestinationConfirmation IS NULL THEN 1 ELSE 0 END) AS unconfirmedToday,
SUM(CASE WHEN Severity = 'Error' THEN 1 ELSE 0 END) AS errorToday
INTO #GenericLeadStats
FROM GenericLeadLogs WITH(NOLOCK)
WHERE [DateCreated] BETWEEN DATEADD(dd,-1,GETDATE()) AND GETDATE()
SELECT * FROM #GenericLeadStats
DROP TABLE #GenericLeadStats
In SQL Server, la clausola SELECT INTO crea una tabella che non esiste già. Lo lascio, ma non serve a nulla in base a ciò che viene fornito.