Link to home
Start Free TrialLog in
Avatar of HLRosenberger
HLRosenbergerFlag for United States of America

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_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
Avatar of CvD
CvD
Flag of Netherlands image

ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HLRosenberger

ASKER

thanks