-1

在此处输入图像描述你好,

我想通过使用来自 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

提前致谢。

4

2 回答 2

0

I suggest to use string functions. REPLACE "Webwatcher re-filter URL for " with blank and use LEFT together with PATINDEX to get the ID and cast is as number.

于 2013-07-16T08:40:36.097 回答
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# 中解析数字或您使用的数字。

于 2013-07-16T06:19:40.137 回答