以下是我的示例存儲過程。當我通過傳遞DATE執行存儲過程時,它顯示的錯誤如下。在SQL SERVER 2005中執行存儲過程時出錯
無效的對象名稱TEMPP「
- 存儲過程
ALTER PROCEDURE [dbo].[mystoredprocedure]
@abc DATETIME //coming fron front-end
AS
BEGIN
SET NOCOUNT ON;
WITH TEMPP AS
(
SELECT DISTINCT(ID), NAME
FROM EMPLOYEE WHERE EMPDATE > @abc
)
select DP.NAME INTO xy from DEPARTMENT DP,TEMPP TE
where DP.ID=TE.ID ;
SELECT * FROM xy;
DROP xy;
END
哪裏是錯誤的?
問候,
JN
可能重複:http://stackoverflow.com/questions/954016/multiple-select-statements-using-sql-server-2005-with-statement – Bravax 2011-03-11 08:25:09
我不這麼認爲 - CTE是隻用一旦。 – Goran 2011-03-11 08:27:25
順便說一句。如果您將select(使用@gbn建議)重寫入連接,錯誤是否仍然存在? – Goran 2011-03-11 08:29:51