SQLTeam.com | Weblogs | Forums

XML Report Error

Hi experts, I'm trying to output a simple XML report. The Syntax checker is flagging every AS 'td', as invalid. So the second As for every column is invalid. Can this be done?
Thanks.

SET @xml = CAST((SELECT dbo_Orgs_1.Name AS 'Carrier 1' AS 'td', '', Orgs.Name as 'Carrier 2' AS 'td', '', ViewTLContracts.EffectiveStartDT as 'StartDT' AS 'td', '',
ViewTLContracts.EffectiveEndDT as 'EndDT' AS 'td','', Count(ViewTLContracts.Id) AS [# of Contracts] AS 'td' FROM (ViewTLContracts INNER JOIN Orgs AS dbo_Orgs_1 ON ViewTLContracts.CarrierOrgId = dbo_Orgs_1.Id) INNER JOIN Orgs ON ViewTLContracts.ParentOrgId = Orgs.Id
GROUP BY dbo_Orgs_1.Name, Orgs.Name, ViewTLContracts.EffectiveStartDT, ViewTLContracts.EffectiveEndDT
HAVING (((ViewTLContracts.EffectiveEndDT) < @30DaysFromNow And (ViewTLContracts.EffectiveEndDT)> @currDate))
FOR XML PATH('tr'), ELEMENTS ) AS NVARCHAR(MAX));

A little sample data as well as the structure of the xml would help.
Help us help you

Also recommend you use aliases

ViewTLContracts tlc

Thanks, yosiaz. I got that resolved but look a the date the query returns. Where is that "T" coming from?

There are multiple Ts in that image

The value in the StartDT column contains a "T". Is that to denote the "Time"
part of the date/time field?

Yep. I encourage you to start looking deeper into documentation. You will have exponential growth in your skills