Northwind Database (Document! X Sample)
AdventureWorks Database / dbo Schema / dbo.uspSearchCandidateResumes Stored Procedure
In This Topic
    dbo.uspSearchCandidateResumes Stored Procedure
    In This Topic
    Properties
    Creation Date27/10/2017 14:33
    Encrypted
    Ansi Nulls
    Parameters
    ParameterDirectionDescriptionData TypeSize
    In VarWChar1000
    In Boolean1
    In Boolean1
    In Integer4
    Return Value Integer4
    Objects that dbo.uspSearchCandidateResumes depends on
     Database ObjectObject TypeDescriptionDep Level
    Person.BusinessEntity tablePerson.BusinessEntityTableSource of the ID that connects vendors, customers, and employees with address and contact information.2
    HumanResources.Employee tableHumanResources.EmployeeTableEmployee information such as salary, department, and title.3
    dbo.Flag datatypedbo.FlagUser Defined Data Type 4
    HumanResources.JobCandidate tableHumanResources.JobCandidateTableRésumés submitted to Human Resources by job applicants.2
    dbo.Name datatypedbo.NameUser Defined Data Type 2
    dbo.NameStyle datatypedbo.NameStyleUser Defined Data Type 5
    Person.Person tablePerson.PersonTableHuman beings involved with AdventureWorks: employees, customer contacts, and vendor contacts.4
    Procedure Source Code
    --A stored procedure which demonstrates integrated full text search
    
    CREATE PROCEDURE [dbo].[uspSearchCandidateResumes]
        @searchString [nvarchar](1000),   
        @useInflectional [bit]=0,
        @useThesaurus [bit]=0,
        @language[int]=0
    
    
    WITH EXECUTE AS CALLER
    AS
    
    BEGIN
        SET NOCOUNT ON;
    
          DECLARE @string nvarchar(1050)
          --setting the lcid to the default instance LCID if needed
          IF @language = NULL OR @language = 0 
          BEGIN 
                SELECT @language =CONVERT(int, serverproperty('lcid'))  
          END
          
    
                --FREETEXTTABLE case as inflectional and Thesaurus were required
          IF @useThesaurus = 1 AND @useInflectional = 1  
            BEGIN
                      SELECT FT_TBL.[JobCandidateID], KEY_TBL.[RANK] FROM [HumanResources].[JobCandidate] AS FT_TBL 
                            INNER JOIN FREETEXTTABLE([HumanResources].[JobCandidate],*, @searchString,LANGUAGE @language) AS KEY_TBL
                       ON  FT_TBL.[JobCandidateID] =KEY_TBL.[KEY]
                END
    
          ELSE IF @useThesaurus = 1
                BEGIN
                      SELECT @string ='FORMSOF(THESAURUS,"'+@searchString +'"'+')'      
                      SELECT FT_TBL.[JobCandidateID], KEY_TBL.[RANK] FROM [HumanResources].[JobCandidate] AS FT_TBL 
                            INNER JOIN CONTAINSTABLE([HumanResources].[JobCandidate],*, @string,LANGUAGE @language) AS KEY_TBL
                       ON  FT_TBL.[JobCandidateID] =KEY_TBL.[KEY]
            END
    
          ELSE IF @useInflectional = 1
                BEGIN
                      SELECT @string ='FORMSOF(INFLECTIONAL,"'+@searchString +'"'+')'
                      SELECT FT_TBL.[JobCandidateID], KEY_TBL.[RANK] FROM [HumanResources].[JobCandidate] AS FT_TBL 
                            INNER JOIN CONTAINSTABLE([HumanResources].[JobCandidate],*, @string,LANGUAGE @language) AS KEY_TBL
                       ON  FT_TBL.[JobCandidateID] =KEY_TBL.[KEY]
            END
      
          ELSE --base case, plain CONTAINSTABLE
                BEGIN
                      SELECT @string='"'+@searchString +'"'
                      SELECT FT_TBL.[JobCandidateID],KEY_TBL.[RANK] FROM [HumanResources].[JobCandidate] AS FT_TBL 
                            INNER JOIN CONTAINSTABLE([HumanResources].[JobCandidate],*,@string,LANGUAGE @language) AS KEY_TBL
                       ON  FT_TBL.[JobCandidateID] =KEY_TBL.[KEY]
                END
    
    END;
    
    See Also