Results 1 to 3 of 3
  1. #1
    Join Date
    May 2015
    Posts
    1

    Unanswered: Transform variable - add operator or

    I wish my transform variable, so that adding the OR operator, and the words within the quotes are not to put the OR.



    ALTER PROCEDURE

    @Product = ' 'ORANGE LEMON' BANANA APPLE 'PEACH PEAR' '

    AS

    -- I WANT TRANSFORM THE WORDS

    @PRODUCT = 'ORANGE LEMON' OR BANANA OR APPLE 'PEACH PEAR'


    SELECT Description
    FROM Production.ProductDescription
    WHERE CONTAINS(Description, @PRODUCT)
    GO

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    That doesn't logically make sense...

    Why isn't there an OR between the words "APPLE" and "PEACH"?
    George
    Home | Blog

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I can't test this without access to your data, but I'm pretty sure that it will do what you requested.
    Code:
    CREATE TYPE simpleusers_type AS TABLE
       (
          name          VARCHAR(99)
       )
    GO
    
    CREATE PROCEDURE simpleusers_sp
      @simpleusers_parm simpleusers_type READONLY
    AS
    
    SELECT t.[Description]
       FROM Production.ProductDescription AS t
       CROSS JOIN @simpleusers_parm AS p
       WHERE  CONTAINS(t.[Description], p.name)
    
    RETURN
    GO
    
    DECLARE @simpleusers_var simpleusers_type
    
    INSERT INTO @simpleusers_var (name)
       VALUES ('ORANGE LEMON'), ('BANANA'), ('APPLE'), ('PEACH PEAR')
    
    EXECUTE simpleusers_sp @simpleusers_var
    
    DROP PROCEDURE simpleusers_sp
    GO
    
    DROP TYPE simpleusers_type
    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •