????2.1 TIP
????Exception message: DataReader.GetFieldType(4) returned null. Exception data: System.Collections.ListDictionaryInternal
??????????п??????????θ????????????????????????????????????????????
????C:Program FilesMicrosoft SQL Server100SDKAssembliesMicrosoft.SqlServer.Types.dll
???????DLL????????????ó??????????????????
????????Ч??????????????????
????DECLARE @tmpIds hierarchyid
????SELECT @tmpIds=Pids FROM EL_Organization.Organization WHERE ID='ecc43c7159924dca91e2916368f923f4';
????WITH CTEGetChild AS  (
????SELECT * FROM EL_Organization.Organization WHERE ID='ecc43c7159924dca91e2916368f923f4'
????UNION ALL(
????SELECT * FROM EL_Organization.Organization WHERE Pids.IsDescendantOf(@tmpIds)=1
????)
????)
????SELECT * FROM CTEGetChild
???????????????????1S???
????2.2 ???????????ò????
?????????????????????????Σ??????????????Σ??磺???????????ó????б??????????????£?????????????Ρ??????????????????????????????????????е?ParentId?????????????????PIds??Σ??????????????????????£?
create trigger UpdateOrgPIds
on EL_Organization.Organization
after update
as
if update ([ParentId])
begin
declare @tmpId varchar(36)
select @tmpId=id from inserted
update EL_Organization.Organization set pids=dbo.f_cidname(@tmpId)
end
go
-- drop  trigger EL_Organization.UpdateOrgPIds