declare myCur Cursor for(select RowGuid, Name from [LY_BIMPM_ModelData].[dbo].[BidSection_BaseInfor] where ProjectRowGuid = ‘61cebf00-bd9a-4f5f-b8e3-359583bfcd71‘) open myCur; declare @BidRowGuid varchar(50),@BidName varchar(50),@PGuid varchar(50)=‘61cebf00-bd9a-4f5f-b8e3-359583bfcd71‘,@ModelGuid varchar(50)=‘61f71964-10b2-4555-91cc-a9fe6fd38355‘ declare @UserGuid varchar(50)=‘755D80DE-75DA-449F-8AF3-60F2600D12ED‘ fetch next from myCur into @BidRowGuid,@BidName while(@@FETCH_STATUS=0) begin INSERT INTO [LY_BIMPM_Document].[dbo].[BidSectionShareDocumentCategory] ([RowGuid] ,[ModuleFunctionRowGuid] ,[ProjectRowGuid] ,[BidSectionRowGuid] ,[ParentRowGuid] ,[Title] ,[Description] ,[SortOrder] ,[CreateUserRowGuid] ,[CreationDate] ,[LastModificationDate]) SELECT NEWID(),@ModelGuid,@PGuid,@BidRowGuid,‘‘,[DesignSpecialityName],‘‘,0,@UserGuid,GETDATE(),GETDATE() FROM [LY_BIMPM_Draw].[dbo].[LocaleDraw] where BIMPM_ProjectInfoRowGuid = ‘61cebf00-bd9a-4f5f-b8e3-359583bfcd71‘ and SubProjectName like ‘%‘[email protected] +‘%‘ group by SubProjectName,DesignSpecialityName fetch next from myCur into @BidRowGuid,@BidName end close myCur