HELP with SQL
Posted on 2013-12-26
I have this SQL. 'ScottPletcher' answered a previous question of mine that gave me this. If you see this post, this SQL works fine in a VIEW. What/how does "FOR XML PATH('')) AS" do? I want to understand how SQL this is working.
Also, although the view works, whenever I open it in design mode, I get an error related to the WHERE clause, which I'm assuming is related to the FOR XML PATH('')) .
SELECT FR.ID, REPLACE(SUBSTRING(CAST
((SELECT CAST('~' + 'Restriction: ' + CONVERT(varchar(10), RES.create_date, 101) + ' - ' + RES.notes AS varchar(8000))
FROM dbo.tds_grant_funding_request_restriction RES
WHERE res.FK_funding_requestID = FR.ID FOR XML PATH('')) AS varchar(8000)), 2, 8000), '~', CHAR(13) + CHAR(10)) AS Restrictions
FROM dbo.tds_grant_funding_request FR