I am uisng Excel Services to extract data from PS2013. And the Multi-line text fields include the </Div> syntax. I have looked at a lot of the links regarding how to do this. I have even borrowed code that was on someones blog. When I try and use it I get the following message and cannot not seem to resolve it after reading varous links regarding this issue.
Any ideas? As a work around I have created an Excel Macro to remove it, however would like to solve it in the query
Error Message
The data types Nvarchar and Ntext are incompatible in the add operator
Here is the syntax
declare @Headxml nvarchar(350)
declare @Footxml nvarchar(50)
set @Headxml = N'<?xml version="1.0"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"
[<!ENTITY nbsp " "><!ENTITY quot """>]><html><body>'
set @Footxml = N'</body></html>'
SELECT ProjectOwner.ProjectUID as [ProjectUID],
ProjectOwner.ProjectName as [Project Name],
ProjectOwner.[Project Number] as [ECP#],
TaskRelated.TaskName as [Task Name],
MSP_WssRiskToTaskLinks_UserView.RiskID as [Risk ID],
MSP_WssRiskToTaskLinks_UserView.Title as [Risk Title],
MSP_WssRiskToTaskLinks_UserView.Status as [Status],
MSP_WssRiskToTaskLinks_UserView.AssignedToResource as [Assigned To],
MSP_WssRiskToTaskLinks_UserView.Owner as [PM],
MSP_WssRiskToTaskLinks_UserView.DueDate as [Due Date],
MSP_WssRiskToTaskLinks_UserView.Probability as [Probability],
MSP_WssRiskToTaskLinks_UserView.Impact as [Impact],
MSP_WssRiskToTaskLinks_UserView.Exposure as [Exposure],
MSP_WssRiskToTaskLinks_UserView.Cost as [Cost],
MSP_WssRiskToTaskLinks_UserView.CostExposure as [Cost Exposure],
MSP_WssRiskToTaskLinks_UserView.Category as [Category],
ISNULL(LTRIM((CONVERT(xml,(@Headxml+MSP_WssRiskToTaskLinks_UserView.[Description]+@Footxml),3)
.value(N'(/)','nvarchar(4000)'))),'') AS [YourMulti-lineCustomFieldNewName],
MSP_WssRiskToTaskLinks_UserView.MitigationPlan as [Mitigation Plan],
MSP_WssRiskToTaskLinks_UserView.ContingencyPlan as [Contingency Plan],
MSP_WssRiskToTaskLinks_UserView.TriggerTask as [Trigger Task],
MSP_WssRiskToTaskLinks_UserView.TriggerDescription as [Trigger Description],
MSP_WssRiskToTaskLinks_UserView.CreatedDate as [Created Date],
MSP_WssRiskToTaskLinks_UserView.CreateByResource as [Create By],
MSP_WssRiskToTaskLinks_UserView.ModifiedByResource as [Modified By],
MSP_WssRiskToTaskLinks_UserView.ModifiedDate as [Modified],
TaskRelated.TaskUID as [TaskUID],
TaskRelated.TaskName as [Task Name],
TaskRelated.TaskStartDate as [Task Start],
TaskRelated.TaskFinishDate as [Task Finish] FROM dbo.MSP_WssRiskToTaskLinks_UserView
LEFT OUTER JOIN dbo.MSP_EpmProject_UserView AS ProjectOwner ON ProjectOwner.ProjectUID = MSP_WssRiskToTaskLinks_UserView.ProjectUID
LEFT OUTER JOIN dbo.MSP_EpmProject_UserView AS ProjectRelated ON ProjectRelated.ProjectUID = MSP_WssRiskToTaskLinks_UserView.RelatedProjectUID
LEFT OUTER JOIN dbo.MSP_EpmTask_UserView AS TaskRelated ON TaskRelated.ProjectUID = MSP_WssRiskToTaskLinks_UserView.RelatedProjectUID
AND TaskRelated.TaskUID = MSP_WssRiskToTaskLinks_UserView.RelatedTaskUID LEFT JOIN dbo.MSP_WssRelationshipType ON
MSP_WssRiskToTaskLinks_UserView.RelationshipTypeID = MSP_WssRelationshipType.RelationshipTypeID
ORDER BY ProjectOwner.ProjectName ASC, MSP_WssRiskToTaskLinks_UserView.RiskID
Andrew Payze