Can anybody tell why is this query not working?
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
Error i get is
`Msg 102, Level 15, State 1, Line 12 Incorrect syntax near '@unwantedRows'. Msg 156, Level 15, State 1, Line 15 Incorrect syntax near the keyword 'As'.
Edit :
Now it's giving with 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'.