We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
@Search varchar(50), @CAT_ID int = 0, @OrderBy int = '', @PageIndex int = 1, @PageSize int = 20 AS BEGIN DECLARE @StartRow int DECLARE @EndRow int SET @StartRow = (@PageSize * (@PageIndex - 1)) + 1 SET @EndRow = @PageSize * @PageIndex + 1 IF (@CAT_ID = 0) BEGIN SET @CAT_ID = Null END SET NOCOUNT ON; WITH RecipeSearch AS ( SELECT DISTINCT ROW_NUMBER() OVER ( -- Dynamic sorting ORDER BY CASE WHEN @OrderBy = 1 THEN HITS END DESC, CASE WHEN @OrderBy = 2 THEN NO_RATES END DESC, CASE WHEN @OrderBy = 3 THEN Name END, CASE WHEN @OrderBy = 4 OR @OrderBy = '' THEN Date END DESC ) AS RowNumber, R1.ID, R1.Name, R1.Author, CAST(R1.Ingredients as nvarchar(max)) as Ingredients, CAST(R1.Instructions as nvarchar(max)) as Instructions, R1.Date, R1.HOMEPAGE, R1.LINK_APPROVED, R1.HITS, R1.RATING, R1.NO_RATES, R1.TOTAL_COMMENTS, R1.HIT_DATE, R1.RecipeImage, R1.FullTextSearch, R1.TimeText, R1.TimeValue, fulltextSearch.[RANK] as SearchRank, Cast((1.0 * RATING/NO_RATES) as decimal(2,1)) as Rates, dbo.GetSearchResultCount(@Search, @CAT_ID) As RCount FROM RECIPES R1 JOIN FreeTextTable(Recipes,FullTextSearch,@Search) fulltextSearch ON R1.[ID] = fulltextSearch.[KEY] WHERE LINK_APPROVED = 1 AND FREETEXT(FullTextSearch,@Search)
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.