HarshalChoksi
yeah thanks for your help,but can you check my storedProcedure as well
Please look at it & if you have any idea of it.
________________________________
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
--
-- spSearch
-- SUMMARY Executes a search using the specified query
-- PARAMS @siteId Identifier of the site from which the search request was generated
-- @query Full-text query to be executed against the full-text engine
--
ALTER PROCEDURE spSearch
(
@siteId INT,
@textOnly BIT,
@query NVARCHAR(4000)
)
AS
-- Select Alternatives
Declare @partialQuery NVARCHAR(50)
Declare @keyphrase NVARCHAR(50)
--Query can be provided like 'searchterm' or as "search term" depending in existance of space character
--must format the partial query if it contains a space like '"search term*"'
--the keyphrase is @query without quotes
IF CHARINDEX(N'"',@query) > 0
BEGIN
SET @partialQuery = LEFT(@query, LEN(@query) - 1) + N'*"'
SET @keyphrase = LEFT(RIGHT(@query, LEN(@query) - 1), LEN(@query) - 2)
END
ELSE
BEGIN
--must format the partial query like '"searchterm*"'
set @partialQuery = N' "' + @query + N'*" '
set @keyphrase = @query
END
--Now we can search for alternatives as exact match of @query on alternatives
--or partial match on keyword, but ignore exact match on keyword (i.e. only alternatives to @query)
SELECT *
FROM tblKeywords
WHERE NOT Keyword = @keyphrase
AND SiteId = @siteId
AND (
CONTAINS(Keyword, @partialQuery )
)
-- Select the pages that match the query
SELECT DISTINCT c.ContentName, c.ContentLongSummary, c.MasterId, nc.NavigationId
FROM tblContents AS c
INNER JOIN trelKeywords AS ck ON ck.MasterId = c.MasterId
INNER JOIN tblKeywords AS k ON k.KeywordId = ck.KeywordId
INNER JOIN trelNavigationContents AS nc ON nc.MasterId = c.MasterId
INNER JOIN GetKeywordsFromQuery (@query) AS kq ON kq.Word = k.Keyword
INNER JOIN tblNavigation AS nav ON nc.NavigationId = nav.NavigationId
WHERE c.SiteId = @siteId
AND c.StatusID = 2
AND c.DeletedBy IS NULL
AND ( (@textOnly=0) or (nav.ExcludeFromTextSite=0 and @textOnly=1) )
UNION -- the following selects list pages that match, with primarylist page as their navigationid
SELECT DISTINCT c.ContentName, c.ContentLongSummary, c.MasterId, nc.NavigationId
FROM tblContents AS c
INNER JOIN trelKeywords AS ck ON ck.MasterId = c.MasterId
INNER JOIN tblKeywords AS k ON k.KeywordId = ck.KeywordId
INNER JOIN tblContents AS c1 ON c.PrimaryListMasterId = c1.MasterId
INNER JOIN trelNavigationContents AS nc ON nc.MasterId = c1.MasterId
INNER JOIN GetKeywordsFromQuery (@query) AS kq ON kq.Word = k.Keyword
INNER JOIN tblNavigation AS nav ON nc.NavigationId = nav.NavigationId
INNER JOIN tblListContents AS lst ON lst.ListItemMasterId = c.MasterId
WHERE c.SiteId = @siteId
AND c.DeletedBy IS NULL
AND c.StatusID = 2
AND c1.statusid = 2
AND c1.DeletedBy IS NULL
AND ( (@textOnly=0) or (nav.ExcludeFromTextSite=0 and @textOnly=1) )
AND lst.ContentMasterId = c.PrimaryListMasterId
-- Select the downloads that match the query
SELECT DISTINCT r.ResourceId, r.ResourceName, r.ResourceLongSummary, r.FileSize
FROM tblResources AS r
INNER JOIN trelKeywordResources AS kr ON kr.ResourceId = r.ResourceId
INNER JOIN tblKeywords AS k ON k.KeywordId = kr.KeywordId
INNER JOIN GetKeywordsFromQuery (@query) AS kq ON kq.Word = k.Keyword
INNER JOIN trelContentItemResources AS cir ON r.ResourceId = cir.ResourceId
WHERE r.ResourceTypeId = 2
AND r.SiteId = @siteId
AND cir.StatusId = 2
SELECT CASE WHEN nc.MasterId IS NULL THEN cir.MasterId ELSE nc.MasterId END AS MasterId, CASE WHEN nc.MasterId IS NULL
THEN ln.NavigationId ELSE nc.NavigationId END AS NavigationId, c.ContentName, res.ResourceId, res.ResourceTextType, res.ResourceText,
c.ContentLongSummary
FROM tblResources res INNER JOIN
trelContentItemResources cir ON cir.ResourceId = res.ResourceId
LEFT OUTER JOIN trelNavigationContents nc ON nc.MasterId = cir.MasterId
LEFT OUTER JOIN tblContents c ON c.MasterId = cir.MasterId AND c.StatusId = cir.StatusId
LEFT OUTER JOIN trelNavigationContents ln ON c.PrimaryListMasterId = ln.MasterId
LEFT OUTER JOIN tblNavigation nav ON nc.NavigationId = nav.NavigationId
INNER JOIN tlkpResourceTypes rt ON rt.ResourceTypeId = res.ResourceTypeId
INNER JOIN tblListContents AS lst ON lst.ListItemMasterId = c.MasterId
WHERE (res.SiteId = @siteId)
AND (res.ResourceTypeId = 1 OR res.ResourceTypeId = 6)
AND CONTAINS(res.ResourceText, @query)
AND (c.ContentPublicationDate IS NOT NULL)
AND (c.DeletedBy IS NULL)
AND (c.StatusId = 2)
AND (nc.MasterId IS NOT NULL)
AND ( (@textOnly=0) or (nav.ExcludeFromTextSite=0 and @textOnly=1) )
OR
(res.SiteId = @siteId)
AND (res.ResourceTypeId = 1 OR res.ResourceTypeId = 6)
AND CONTAINS(res.ResourceText, @query)
AND (c.ContentPublicationDate IS NOT NULL)
AND (c.DeletedBy IS NULL)
AND (c.StatusId = 2)
AND (c.PrimaryListMasterId IS NOT NULL)
AND ( (@textOnly=0) or (nav.ExcludeFromTextSite=0 and @textOnly=1) )
ORDER BY rt.SearchResultOrder, c.ContentName
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
__________________________________________
you call the SP you should prefix the N
in this sp, i m using three times that function. even i m not getting how to call the sp with it should have prefix the N....please let me know. i am just waiting for your reply.even i have using NVARCHAR whereever i stored a hindi text...i hope you have already seen my function.please do the needful. i have tried lot since few days on this, still couldn't get the right solution.