有人可以告訴爲什麼這個查詢不起作用嗎?爲什麼@Table不適合我?
DECLARE @unwantedRows TABLE
(
ProductId INT,
ProductName VARCHAR(50),
Description VARCHAR(50),
Category VARCHAR(50),
Repetitions VARCHAR(50)
);
Select *
INTO @unwantedRows From
(
Select a.*,Row_Number() Over(Partition By ProductId Order By ProductId) As [Repetitons] from tblProduct a
) As A
Where A.Repetitons > 1
錯誤我得到的是
`消息102,級別15,狀態1,行12 附近有語法錯誤@unwantedRows「。 Msg 156,Level 15,State 1,Line 15 關鍵字'As'附近的語法不正確。
編輯:
現在,它與Repetitions
,並提供: -
INSERT
INTO @unwantedRows
Select a.*,Row_Number() Over(Partition By ProductId Order By ProductId) As [Repetitons] from tblProduct a
Where a.Repetitons > 1
`
Invalid column name 'Repetitons'.
檢查更新,插入查詢 – 2010-07-28 11:03:41
你拼寫錯誤重複次數的查詢,但沒有在表中。 – HLGEM 2010-07-28 17:42:04