Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2013
    Posts
    7

    Unanswered: Using Like in If condition

    Hi..

    A value is being passed to the procedure as a parameter. Within this procedure, can another variable be declared to hold this value and apply some conditions like:

    if @sample is the parameter being passed to the proc externally,
    will the below be possible inside the procedure:

    Code:
    declare @sam char(9)
    select sam=@sample
    
    if ( @sam like 'A%')
    begin
    ---
    ---
    else
    ---
    ---
    end
    Any help would be greatly appreciated.

    Many thanks

  2. #2
    Join Date
    Oct 2002
    Location
    BC, Canada
    Posts
    17
    No, it won't work. You should compare them using a substring function.
    Marin Kostadinovic
    ----------------------------
    DBA
    DIMM Info Systems Inc.


  3. #3
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Yes you can. You need an @
    select @sam=@sample

Posting Permissions

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