Direct data entry to PrincipalObjectAccess Table using SQL Query.
It is an unsupported approach. Try below SQL query to insert the records in PrincipalObjectAccess table from your table (i have taken the table name as backupTable).
Declare @SystemUser nvarchar(100)
Declare @ObjectId nvarchar(100)
DECLARE @ObjectTypeCode INT
DECLARE @UserType INT
DECLARE @Accessmask INT
DECLARE @InheritedAccessmask INT
declare Cur_SHAREWITHUSER cursor for
Select ObjectId,Principalid, ObjectTypeCode, PrincipalTypeCode, AccessRightsMask, InheritedAccessRightsMask from backupTable -- (CHange the backup table name)
where AccessRightsMask>0 OR InheritedAccessRightsMask>0
open Cur_SHAREWITHUSER
fetch Cur_SHAREWITHUSER into @ObjectId,@SystemUser,@ObjectTypeCode, @UserType, @Accessmask, @InheritedAccessmask
while(@@fetch_status=0)
BEGIN
INSERT INTO PrincipalObjectAccess
(Principalid,ObjectId,ObjectTypeCode,[PrincipalTypeCode],[AccessRightsMask],ChangedOn,
[InheritedAccessRightsMask] ,PrincipalObjectAccessId )
values (@SystemUser , @ObjectId ,@ObjectTypeCode,@UserType,@Accessmask,GETDATE(),@InheritedAccessmask,NEWID())
fetch Cur_SHAREWITHUSER into @ObjectId,@SystemUser,@ObjectTypeCode, @UserType,@Accessmask, @InheritedAccessmask
END
close Cur_SHAREWITHUSER
deallocate Cur_SHAREWITHUSER
It is an unsupported approach. Try below SQL query to insert the records in PrincipalObjectAccess table from your table (i have taken the table name as backupTable).
Declare @SystemUser nvarchar(100)
Declare @ObjectId nvarchar(100)
DECLARE @ObjectTypeCode INT
DECLARE @UserType INT
DECLARE @Accessmask INT
DECLARE @InheritedAccessmask INT
declare Cur_SHAREWITHUSER cursor for
Select ObjectId,Principalid, ObjectTypeCode, PrincipalTypeCode, AccessRightsMask, InheritedAccessRightsMask from backupTable -- (CHange the backup table name)
where AccessRightsMask>0 OR InheritedAccessRightsMask>0
open Cur_SHAREWITHUSER
fetch Cur_SHAREWITHUSER into @ObjectId,@SystemUser,@ObjectTypeCode, @UserType, @Accessmask, @InheritedAccessmask
while(@@fetch_status=0)
BEGIN
INSERT INTO PrincipalObjectAccess
(Principalid,ObjectId,ObjectTypeCode,[PrincipalTypeCode],[AccessRightsMask],ChangedOn,
[InheritedAccessRightsMask] ,PrincipalObjectAccessId )
values (@SystemUser , @ObjectId ,@ObjectTypeCode,@UserType,@Accessmask,GETDATE(),@InheritedAccessmask,NEWID())
fetch Cur_SHAREWITHUSER into @ObjectId,@SystemUser,@ObjectTypeCode, @UserType,@Accessmask, @InheritedAccessmask
END
close Cur_SHAREWITHUSER
deallocate Cur_SHAREWITHUSER
1 comment:
I really appreciate spending some time to talk about that, I believe firmly regarding this and so really enjoy understanding more about this kind of subject.This is also a very good post which I really enjoyed reading. It is not everyday that I have the possibility to see something like this. CRM Software || MLM Software in Mumbai || ERP Software || System Software in Mumbai
Post a Comment