set @PropertyList='select distinct
P.PropertyName
from
Property P
join
ContactAssignment CA on CA.AssociatedObjectId = p.PropertyID
left join
contactsubtype CS on CS.ContactSubTypeName = CA.SubType
where
' + Charindex('' + cast('' + PropertyID + '' as varchar(8000)) + '', @array) > 0 + '
and Cs.ContactSubTypeID not in (' + @Contactindselect + ')'
答案 0 :(得分:0)
请尝试以下查询:
select
distinct P.PropertyName
from
Property P
join ContactAssignment CA on CA.AssociatedObjectId = p.PropertyID
left join contactsubtype CS on CS.ContactSubTypeName = CA.SubType
where
'+Charindex(''+cast(''+PropertyID+'' as varchar(8000))+'', @array) > 0+'
and Cs.ContactSubTypeID not in ('+@Contactindselect+')