sqlserver拼接字段截取
⽅式⼀:
--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

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。