'>'附近的语法不正确

时间:2019-03-01 04:36:41

标签: sql

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 + ')'

1 个答案:

答案 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+')