Question : Simple query not working. What am i missing?

Hello,

Sql2008

I have posted two queries, the first works, but the second does not. Where am i going wrong?

thank you
Code Snippet:
1:
2:
3:
4:
5:
-- Works when i place the guid into the query
exec sp_executesql N'SELECT Id  FROM tProduct WHERE cast(RelatedProducts as varchar(8000)) like ''%cffc83d0-094a-4f61-8728-18efe1509781%'' AND DateExpired is null',N'@ProductGuid nvarchar(36)',@ProductGuid=N'cffc83d0-094a-4f61-8728-18efe1509781'

-- Does not work as i want it to
exec sp_executesql N'SELECT Id FROM tProduct WHERE cast(RelatedProducts as varchar(8000)) like ''%@ProductGuid%'' AND DateExpired is null',N'@ProductGuid nvarchar(36)',@ProductGuid=N'cffc83d0-094a-4f61-8728-18efe1509781'

Answer : Simple query not working. What am i missing?

exec sp_executesql N'SELECT Id FROM tProduct WHERE cast(RelatedProducts as varchar(8000)) like ''%'' + @ProductGuid + ''%'' AND DateExpired is null',N'@ProductGuid nvarchar(36)',@ProductGuid=N'cffc83d0-094a-4f61-8728-18efe1509781'
Random Solutions  
 
programming4us programming4us