我在执行以下代码时遇到问题:
DECLARE @CUTOFFDAYS_i INT
DECLARE @SQL NVARCHAR(MAX)
DECLARE @SQL1 NVARCHAR(MAX)
SET @CUTOFFDAYS_i = 750
CREATE TABLE #TMP(
EMPID INT,
EMPNAME VARCHAR(35)
)
SET @SQL = 'SELECT EMPID, EMPNAME INTO #TMP FROM EMPDB..EMPTABLE
WHERE DATEDIFF(DAY, CREATEDDATE, GETDATE()) > @CUTOFFDAYS_i
AND ERRORMESSAGE = '''''
SET @SQL1 = 'SELECT * FROM #TMP'
EXEC SP_EXECUTESQL @SQL
EXEC SP_EXECUTESQL @SQL1
即使那样我也没有得到任何结果
SELECT * FROM #TMP