关键字:
microsoft project server
enterprise project outline code
涉及的表
表名 | 说明 |
MSP_WEB_PROJECTS | 项目表 |
MSP_CODE_FIELDS | 大纲代码Field_ID和Code_UID对应表 |
MSP_OUTLINE_CODES | 大纲代码表 |
MSP_FIELD_ATTRIBUTES | 定义域属性;该表包含与域属性(如自定义 WBS、自定义域名称别名和自定义域公式等)有关的数据。 |
MSP_ATTRIBUTE_STRINGS | 该表存储在 MSP_FIELD_ATTRIBUTES 中所定义的自定义 WBS 代码定义、别名和公式 |
先通过定义的大纲代码名称找到大纲代码的FieldID
declare @tFieldValue varchar(300)
set @tFieldValue = 'Project Status'
declare @FieldID int –定义大纲的域字段
--取得全局项目的Proj_ID
declare @GlobalProjID int
SELECT @GlobalProjID=PROJ_ID FROM MSP_PROJECTS WITH (NOLOCK, INDEX=I_MSP_PROJECTS_PROJ_TYPE) WHERE PROJ_TYPE = 2
SELECT
@FieldID = A.ATTRIB_FIELD_ID
FROM MSP_FIELD_ATTRIBUTES A,MSP_ATTRIBUTE_STRINGS B
WHERE
A.PROJ_ID = B.PROJ_ID
AND A.AS_ID = B.AS_ID
AND A.ATTRIB_FIELD_ID >= 188744529
AND A.ATTRIB_FIELD_ID <= 188744768
AND A.ATTRIB_ID = 206
AND A.PROJ_ID = @GlobalProjID
and b.AS_VALUE = @tFieldValue
--ORDER BY A.ATTRIB_FIELD_ID
ATTRIB_FIELD_ID AS_VALUE
--------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
188744589 Project Status
It is 188744589
在根据全局项目@GlobalProjID和大纲代码的@FieldID,以及设置的状态值取得CODE_UID
declare @stautsValue varchar(300)
set @stautsValue='In progress'
declare @code_uid int
select
@code_uid = CODE_UID
FROM MSP_OUTLINE_CODES
WHERE
PROJ_ID = @GlobalProjID AND
OC_CACHED_IS_VALID > 0 AND OC_FIELD_ID IN (@FieldID) AND CODE_UID > 0
--ORDER BY OC_FIELD_ID,CODE_UID
and cast(OC_NAME as varchar(300)) = @stautsValue
print @code_uid
再根据这个@code_uid 到表MSP_CODE_FIELDS 来查看所有在运行的项目
select * from MSP_WEB_PROJECTS
where
PROJ_ID
in
(
select Proj_ID from MSP_CODE_FIELDS
where code_uid = @code_uid