您好
我想通过使用ProecssInstanceName列中的SQL查询来获取唯一编号。快照附在下面。
现在我正在使用此查询来获取以下结果。查询是
select c.StreamName AS Category,ProcessInstanceAppianID as jobId,a.ProcessInstanceName,a.ProcessInstanceTargetDate AS TargetDate,a.ProcessInstanceDescription as TaskDescription,b.Name as department
from InternalUseOnly..ProcessInstance a
join InternalUseOnly..Departments b on b.KeyDepartment=a.KeyDepartmentEntered AND b.updoperation <2
join InternalUseOnly..ProcessStream c on c.KeyProcessStream=a.KeyProcessStream and c.updoperation <2
where ProcessInstanceCompleted is null
and a.KeyProcessStream in
(330) and a.updoperation <2
提前致谢。
答案 0 :(得分:0)
你想要这个吗?
select c.StreamName AS Category,ProcessInstanceAppianID as jobId,a.ProcessInstanceName,a.ProcessInstanceTargetDate AS TargetDate,a.ProcessInstanceDescription as TaskDescription,b.Name as department,
SUBSTRING(ProcessInstanceName,NULLIF(PATINDEX('%[0-9][0-9][0-9][0-9][0-9][0-9][0-9]%',ProcessInstanceName),0),7) as code
from InternalUseOnly..ProcessInstance a
join InternalUseOnly..Departments b on b.KeyDepartment=a.KeyDepartmentEntered AND b.updoperation <2
join InternalUseOnly..ProcessStream c on c.KeyProcessStream=a.KeyProcessStream and c.updoperation <2
where ProcessInstanceCompleted is null
and a.KeyProcessStream in
(330) and a.updoperation <2
编辑: 我做了这个:
SUBSTRING(ProcessInstanceName, PatIndex('%[0-9]%', ProcessInstanceName), (LEN(ProcessInstanceName) - (PatIndex('%[0-9]%', ProcessInstanceName) - 1) - (PatIndex('%[0-9]%', REVERSE(ProcessInstanceName)) - 1)) + 1)
但我认为这是疯狂的,更好的是用C#解析数字或者你使用的是什么。
答案 1 :(得分:0)
我建议使用string functions。 REPLACE
“Webwatcher重新过滤”空白的网址,并使用LEFT
和PATINDEX
一起获取ID并转换为数字。