I'm using SQL Server 2008.
I have a view called testView
In the view one of the columns is using another query taken from this page - http://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/
ie along this format
Create View testView as
SELECT p1.CategoryId,
( SELECT ProductName + ','
FROM Northwind.dbo.Products p2
WHERE p2.CategoryId = p1.CategoryId
ORDER BY ProductName
FOR XML PATH('') ) AS Products
FROM Northwind.dbo.Products p1
When the following query is run, it is taking about 110 seconds for when there are 60,000 rows in the view.
select * from testView where Products like '%asdf%'
What suggestions can be provided for improving this query?