<和> sql语句的问题

时间:2013-11-12 18:02:32

标签: sql sql-server

我对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

如果我注释掉& lt并保持它运行的where子句但我得到了错误的答案。如果有人能告诉我如何处理该代码,我们将不胜感激。

1 个答案:

答案 0 :(得分:2)

在SQL语句中,您需要使用实际字符<而非HTML实体&lt;> &gt。如果要在Web表单中执行此语句,则需要将实体解码为实际的字符表示形式。