I have variable @count of datatype int.I am setting values to this @count.
I want to select top @count number of rows from table. When i use Select top @count
, its showing error.
IF (@NewItemCount<@OldItemCount)
BEGIN
set @count=@OldItemCount-@NewItemCount
if(@count>0)
BEGIN
Delete from ItemDetails where GroupId in (Select Top @count Id from ItemDetails where GroupId=@Prm_GroupId )
END
END
The error is
Incorrect syntax near '@count'.