SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using "LIKE" in stored procedure

    Hi there... having real brain hurt with a stored procedure:

    Code:
    ALTER PROCEDURE [dbo].[SearchClaimants] 
    	-- Add the parameters for the stored procedure here
    	@criteria char(20),
    	@col char(20)
    	
    AS
    
    	SELECT forename_str + ' ' + surname_str AS Name, nino_str as NINO, address1_str AS Address 
                    FROM claimant 
                    WHERE surname_str LIKE 'm' + '%'
    				--WHERE surname_str LIKE '%ste%'
                 ORDER BY Name
        
    
    
    exec searchclaimants @criteria = 'm', @col = 'str_surname'

    Now... this works and returns the expected results, but when I actually try to substitute the 'm' for the @criteria variable it doesn't work.
    Can anyone tell me if there is a problem with using LIKE in a sp?

    THanks.

    DS

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorted -
    need varchar instead of char

    THanks,.

    DS


Bookmarks

Posting Permissions

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