 <pre><code>declare @query varchar(8000) select @query=' SELECT * FROM Products WHERE Name LIKE ''%' + replace((SELECT TOP 1 Gift.name FROM Gift),' ','%'' or name like ''%') + '%''' exec (@query) </code></pre>