拼接字符串
SELECT [TYPE], STUFF(
( SELECT ','+ [Name]
FROM test b
WHERE b.Type = a.Type
FOR XML PATH('')),1 ,1, '') [Names]
from Test a
group by [TYPE]
拆分字符串
select t3.ID AS RYID ,t3.JGMXIDS as JGMXIDS ,t3.DEPT,t3.TASKID from (
select A.ID , B.JGMXIDS,A.DEPT,A.TASKID from (
SELECT ID, JGMXIDS = CONVERT(xml,'<root><v>' + REPLACE(JGMXIDS , ',', '</v><v>') + '</v></root>'),DEPT,TASKID FROM HFJWD_DZCQ_FLOW_RY) A
outer apply(
SELECT JGMXIDS = N.v.value('.', 'varchar(300)') FROM A.JGMXIDS .nodes('/root/v') N(v)) B) t3
截取字符串
select DICTTYPEID ,DICTID,DICTNAME ,startTime =1 ,endTime =1 from BPM_SYS_DICT_ENTRY where DICTTYPEID='HFJWD_YY_DZCQ_CB'
union all
select DICTTYPEID ,DICTID,DICTNAME=1,
SUBSTRING( DICTNAME , 0 , CHARINDEX('-',DICTNAME) ) startTime ,
SUBSTRING( DICTNAME , CHARINDEX('-',DICTNAME)+1 , len(DICTNAME)-charindex('-',DICTNAME) ) endTime
from BPM_SYS_DICT_ENTRY where DICTTYPEID='HFJWD_YY_DZCQ_SJ'
SQL 拼接字符串,拆分字符串,截取字符串
最新推荐文章于 2024-08-16 09:32:33 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)