• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What am I doing wrong in this Stored Procedure

 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a stored procedure for MSSQL 2000 procedure search_result(@name VARCHAR,@address varchar)
AS
IF((@name IS NOT NULL AND @name <> '' AND @name <> ' ') AND(@address IS NULL OR @address <> '' OR @address <> ' '))
BEGIN
SELECT [postal_code]
FROM OM
WHERE [name] LIKE '%@name%'
END
.....
GO
Nothing is being returned I have tried it in the query analyzer
 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
figured my problem
where [name] like '%@name%'
should read where [name] like '%' + @name + '%'
 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
figured my problem
where [name] like '%@name%'
should read where [name] like '%' + @name + '%'
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic