我正在創建一個存儲過程,但它會引發錯誤。 有人可以告訴我,如果有什麼我做錯了。創建存儲過程中的問題
CREATE TABLE tbl1 (ID int)
INSERT INTO tbl1 SELECT 1
CREATE TABLE tbl2 (ID int)
INSERT INTO tbl2 SELECT 2
CREATE PROCEDURE QOTD (@source INT)
AS
BEGIN
IF @source = 1
SELECT ID INTO #tmpID FROM tbl1
ELSE
SELECT ID INTO #tmpID FROM tbl2
SELECT ID FROM #tmpID
END
ERROR:There is already an object named '#tmpID' in the database.
@Mitch小麥,你怎麼在編譯時解釋錯誤?我很確定這是因爲這是一個語法錯誤,因爲這個對象已經存在了,所以'SELECT ID INTO #tmpID FROM tbl1'。 – 2010-11-18 12:11:55