游标使用之四
declare @PGuid varchar(50)='61cebf00-bd9a-4f5f-b8e3-359583bfcd71' declare @ModelGuid varchar(50)='61f71964-10b2-4555-91cc-a9fe6fd38355' declare @UserGuid varchar(50)='755D80DE-75DA-449F-8AF3-60F2600D12ED' declare @Guid varchar(50)='' declare myCur Cursor for(select SubProjectName,DesignSpecialityName,DrawNumber,DrawName,StorageName from [LY_BIMPM_Draw].[dbo].[LocaleDraw] where BIMPM_ProjectInfoRowGuid = @PGuid) open myCur declare @SubName varchar(50),@SName varchar(50),@DrawNumber varchar(50),@DrawName varchar(50),@StorageName varchar(50) fetch next from myCur into @SubName,@SName,@DrawNumber,@DrawName,@StorageName while(@@FETCH_STATUS=0) begin ---查找分类 INSERT INTO [dbo].[BidSectionShareDocumentEFile] ([RowGuid] ,[ProjectRowGuid] ,[BidSectionRowGuid] ,[FunctionModuleRowGuid] ,[ParentRowGuid] ,[CreateUserRowGuid] ,[CreateUserName] ,[Number] ,[Title] ,[Size] ,[ExtendName] ,[StorageName] ,[Description] ,[CreateDate] ,[LastModificationDate] ,[FirstVersionRowGuid] ,[IsMaxVersion]) select NEWID(),@PGuid,bid.RowGuid, @ModelGuid,cate.RowGuid,@UserGuid,'系统管理员',@DrawNumber,@DrawName,0,'.dwf',@StorageName,'',GETDATE(),GETDATE(), '',1 from [LY_BIMPM_ModelData].[dbo].[BidSection_BaseInfor] as bid, [LY_BIMPM_Document].[dbo].[BidSectionShareDocumentCategory] as cate where @SubName like '%'+bid.Name+'%' and bid.ProjectRowGuid = @PGuid and cate.Title = @SName and cate.BidSectionRowGuid = bid.RowGuid fetch next from myCur into @SubName,@SName,@DrawNumber,@DrawName,@StorageName end close myCur