HLRosenberger
asked on
HELP with SQL
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('')) .
Thanks.
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_requ est_restri ction 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_requ est FR
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('')) .
Thanks.
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_requ
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_requ
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
http://technet.microsoft.com/en-us/library/ms178107.aspx