Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    12

    Unanswered: Stored Procedure involves sql "LIKE" Problem

    Hi there,

    I'm writing a stored procedure for a searching sql , below is the codes

    Code:
    CREATE PROCEDURE stp_SearchShop
    @ShopName varchar(50)
    
    AS
    
    select shop_id,shop_name from shop where shop_name like %@ShopName%
    GO
    Sql Server returns error : Incorrect Syntax Code near '@ShopName' .
    May i know how to implement LIKE SQLs in stored procedure? thanks a lot

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    try this --

    ... where shop_name like '%' & @ShopName & '%'

    EDIT: wait a sec, maybe it has to be this --

    ... where shop_name like '%' + @ShopName + '%'

    (grumble, mumble, stupid non-standard microsoft)
    Last edited by r937; 02-22-05 at 14:13.
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2003
    Posts
    12
    deleted

Posting Permissions

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