我对sql和xml比较新,但有一个应用程序报告生成器,它会为非常复杂的查询生成sql(无论如何),然后我尝试剪切并粘贴到sql server。我似乎无法让这个工作。任何帮助将不胜感激。
Select distinct a.IncidentID, IsNull(i.CompName,'') As 'CompanyName' , IsNull(l.UserDefined2,'') As 'SalesStageDesc' , IsNull(l.UserDefined6,'') As 'UserDefined6' , IsNull(l.UserDefined1,'') As 'SalesTypeDesc' , IsNull(g.ContactName,'') As 'User'
From tblIncident a
LEFT OUTER JOIN tblCompany i with (nolock) ON a.CompanyID = i.CompanyID
LEFT OUTER JOIN tblIncidentUtilityCross l with (nolock) ON a.IncidentID = l.IncidentIDx
LEFT OUTER JOIN (select a.ContactName, b.IncidentID from tblContact a JOIN tblIncidentContact b ON a.ContactID = b.ContactID where (b.contacttypeid = 4 or b.ContactTypeID = 3)) g ON a.IncidentID = g.IncidentID <IncidentHierarchy>
Where a.noreportdisplay !=1
如果我注释掉&amp; lt并保持它运行的where子句但我得到了错误的答案。如果有人能告诉我如何处理该代码,我们将不胜感激。
答案 0 :(得分:2)
在SQL语句中,您需要使用实际字符<
而非HTML实体<
和>
>
。如果要在Web表单中执行此语句,则需要将实体解码为实际的字符表示形式。