方式一:

--select @p_AllPARTOFCHECK = (select CAST(t.PARTOFCHECK as varchar)+'|' from QUEUEDETAIL t where t.APPOINTSID = @p_APPOINTSID for xml path('') )
--select @p_AllDirection = (select CAST(t.DIRECTION as varchar)+'|' from QUEUEDETAIL t where t.APPOINTSID = @p_APPOINTSID for xml path('') )

拼接结构如:字符串A|字符串B|

 

方式二:

 select @p_AllPARTOFCHECK = (stuff((select '|' + PARTOFCHECK from QUEUEDETAIL where appointsid = @p_APPOINTSID for xml path('')),1,1,'')) 

select @p_AllDirection = (stuff((select '|' + direction from QUEUEDETAIL where appointsid = @p_APPOINTSID for xml path('')),1,1,''))

拼接结构如:字符串A|字符串B

 

注:具体拼接分割符,可自行定义使用,示例中使用 | 进行拼接

 

--截取

select SUBSTRING(t.AGE,1,CHARINDEX('岁',t.AGE,2)) as age ,t. * from VIEW_PRINT t
where CHARINDEX('岁',t.AGE,2) >-1

相关文章: