DECLARE my_cursor1 Cursor--Define cursor
for (SELECT RowGuid, projectrowguid from [bimpm_base].[ DBO]. [Projectpermission_role] where subsystemrowguid = ' a9318399-66fe-423e-93f5-ccd7c0a471c4 ')--finds the desired set to be placed in the cursor
OPEN my_ Cursor1; --OPEN cursor
declare @RoleRowGuid varchar (@ProjectRowGuid varchar)
fetch NEXT from My_cursor1 to @RoleRowGuid , @ProjectRowGuid
while (@ @FETCH_STATUS =0)
Begin
---Inner loop
declare Cursor22 CURSOR for (select RowGuid from [ Bimpm_base]. [dbo]. [Projectpermissionitem] where subsystemrowguid = ' a9318399-66fe-423e-93f5-ccd7c0a471c4 ')
OPEN Cursor22
DECLARE @ItemRowGuid varchar
FETCH NEXT from Cursor22 to @ItemRowGuid
while (@ @FETCH_STATUS =0)
Begin
Insert into [bimpm_base]. [dbo]. [Projectpermission_menurole] (PROJECTROWGUID,PERMISSIONITEMROWGUID,ROLEROWGUID,SUBSYSTEMROWGUID)
Values (@ProjectRowGuid, @ItemRowGuid, @RoleRowGuid, ' a9318399-66fe-423e-93f5-ccd7c0a471c4 ')
fetch NEXT from Cursor22 into @ItemRowGuid
End
Close Cursor22
FETCH NEXT from My_cursor1 to @RoleRowGuid, @ProjectRowGuid---move cursor
End
Close My_cursor1
Use of Cursors