有人可以告诉为什么这个查询不起作用吗?为什么@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