April 29, 2003 at 3:04 pm
Hi,
I've got table Product with column Description. Description can contain character "'". I use sp to seach for products as follows:
create procedure SearchProduct
(
@Desc varchar(50)
)
AS
SELECT * FROM Product
WHERE Description LIKE '%@Desc%'
GO
If @Desc contais "'" character (e.g. "John's") sp fails.
How do I fix this?
Thanks.
dusan
April 29, 2003 at 5:41 pm
Hi,
The following code may solve your problem :
CREATE PROCEDURE SearchProduct
( @Desc VARCHAR(50) )
AS
BEGIN
SELECT @Desc = Replace(@Desc, '''', '''''')
SELECT * FROM Product
WHERE Description LIKE '%' + @Desc + '%'
END
GO
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply