Why give this Error???
ALTER proc [dbo].[Mysp_selecttop_with_favorite]
@sort bit = 0
as
declare @tt as TABLE
(
[CategoryID] [tinyint] NOT NULL,
[ItemID] [int] NULL,
[ItemTitle] [nvarchar](4000) NULL,
[ItemDate] [datetime] NULL,
[MinutesAgo] [int] NULL,
[ItemInsertDate] [datetime] NULL,
[ItemImageMainURL] [varchar](4000) NULL,
[ItemImageLocalURL] [varchar](4000) NULL,
[ItemURL] [nvarchar](4000) NULL,
[ItemDescription] [nvarchar](max) NULL,
[ExDate] [datetime] NULL
)
INSERT INTO @tt(CategoryID,ItemID,ItemTitle,ItemDate,MinutesAgo,ItemInsertDate,ItemImageMainURL,ItemImageLocalURL,ItemURL,ItemDescription)
execute ('Mysp_CategoryAllFeedsItems_SelectTop')
UPDATE @tt
SET
[@tt].ItemID=tblFavorite.ItemID,
[@tt].ItemTitle = tblFavorite.ItemTitle,
[@tt].ItemDate=tblFavorite.ItemInsertDate,
[@tt].MinutesAgo=tblFavorite.MinutesAgo,
[@tt].ItemInsertDate=tblFavorite.ItemInsertDate,
[@tt].ItemImageMainURL=tblFavorite.ItemImageMainURL,
[@tt].ItemImageLocalURL=tblFavorite.ItemImageLocalURL,
[@tt].ItemURL=tblFavorite.ItemURL,
[@tt].ItemDescription=tblFavorite.ItemDescription
FROM tblFavorite
WHERE
[@tt].CategoryID = tblFavorite.CategoryID AND (DATEDIFF(minute, tblFavorite.ExDate, GETDATE())) <=0
select case(@sort)
when 0 then (SElect top 4 * from @tt order by CategoryID asc)
when 1 then (SElect top 4 * from @tt order by CategoryID desc)
end