Back

Flexi Time System

Using LIKE with SQL Server Stored Procedures - Problems With The % Sign

Problem

You are passing a parameter @xxx to a stored procedure in SQL Server. The parameter is being used in the WHERE clause with LIKE qualifier. For example:  

Select Title from Publishers WHERE Title LIKE '%@xxx%'

The query will not return a recordset.

Solution

My guess is that you want to use:

select title from publishers where title like '%' + @xxx + '%'

If that doesn't work, try '%' + ltrim(rtrim(@xxx)) + '%', but I don't think you'll need to. 

 

 

Back


Make a Comment on this Article

Your Name:
Comment:

 

Net-Aspect Wakefield (West Yorkshire) Web Design Services Call 01924 918 177