2

I'm relatively new to sql and xml but have an application report generator that will generate the sql for queries that are very complex (to me anyway) and I try and cut and paste then to sql server. I just cant seem to get this one to work. Any help would be appreciated.

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

if I comment out the &lt and keep the where clause it runs but I get the wrong answer. If someone could tell me what to do with that code it would be appreciated.

4

1 回答 1

2

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

于 2013-11-12T18:04:26.490 回答