Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Posts
    162

    Unanswered: SET more then one variable

    How can i have more then one SET in a condition?

    i have this:
    IF @sortorder like '0' and (@Search ='""' OR @search = ' ')
    SET @From ='
    FROM logs L WITH (NOLOCK)
    INNER JOIN users U WITH (NOLOCK) ON L.userID = U.userID '
    ELSE

    I would like to have a second variable set when above is true but i don't know how to put in it.

    something like:
    IF @sortorder like '0' and (@Search ='""' OR @search = ' ')
    SET @From ='
    FROM logs L WITH (NOLOCK)
    INNER JOIN users U WITH (NOLOCK) ON L.userID = U.userID '
    AND SET @Search ='whatever'
    ELSE

  2. #2
    Join Date
    Apr 2012
    Posts
    213
    Try something like that:

    Code:
    IF @sortorder like '0' and (@Search ='""' OR @search = ' ')
        BEGIN
          SET @From = '
              FROM logs L WITH (NOLOCK)
              INNER JOIN users U WITH (NOLOCK) ON L.userID = U.userID ';
          SET @Search = 'whatever';
        END
    ELSE
    Hope this helps.

  3. #3
    Join Date
    Mar 2004
    Posts
    162
    nope that diden't work (incorrect syntax)

  4. #4
    Join Date
    Mar 2004
    Posts
    162
    does anyone have any idea?

  5. #5
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Code:
    DECLARE @this VARCHAR(20)
    ,  @that VARCHAR(20)
    
    SELECT @this = 'Whoopie!', @that = 'That''s Fun!'
    
    SELECT @this, @that
    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  6. #6
    Join Date
    Mar 2004
    Posts
    162
    thanks for that

Posting Permissions

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