游标使用之二

----循环查找构件表,在构件关系表中,给每个构件关联4张图纸
declare @itemRowGuid varchar(50) declare auth_cur cursor for select RowGuid from [BIMPM_RoadBridge].[dbo].[ProjectConstructionItemInfo] where BidSectionRowGuid = '8373de62-4f87-4ca4-b741-30da6491785f-1' open auth_cur fetch next from auth_cur into @itemRowGuid while(@@FETCH_STATUS=0) begin INSERT INTO [dbo].[ProjectConstructionItemInfo_Relation] ([RowGuid],[ProjectConstructionItemInfoRowGuid],[RelationRowGuid],[RelationType],[ProjectRowGuid],[BidSectionRowGuid]) VALUES (NEWID(),@itemRowGuid,'3bb81ad1-c2c0-49b2-989f-57fdc7d833b8',1,'60ff4b50-2227-4ad2-8950-f7cdab801d6a','8373de62-4f87-4ca4-b741-30da6491785f-1') INSERT INTO [dbo].[ProjectConstructionItemInfo_Relation] ([RowGuid],[ProjectConstructionItemInfoRowGuid],[RelationRowGuid],[RelationType],[ProjectRowGuid],[BidSectionRowGuid]) VALUES (NEWID(),@itemRowGuid,'462e458b-24cc-4195-9df1-8e5bb69b7aa5',1,'60ff4b50-2227-4ad2-8950-f7cdab801d6a','8373de62-4f87-4ca4-b741-30da6491785f-1') INSERT INTO [dbo].[ProjectConstructionItemInfo_Relation] ([RowGuid],[ProjectConstructionItemInfoRowGuid],[RelationRowGuid],[RelationType],[ProjectRowGuid],[BidSectionRowGuid]) VALUES (NEWID(),@itemRowGuid,'21978931-d354-4185-993a-194e4b41479e',1,'60ff4b50-2227-4ad2-8950-f7cdab801d6a','8373de62-4f87-4ca4-b741-30da6491785f-1') INSERT INTO [dbo].[ProjectConstructionItemInfo_Relation] ([RowGuid],[ProjectConstructionItemInfoRowGuid],[RelationRowGuid],[RelationType],[ProjectRowGuid],[BidSectionRowGuid]) VALUES (NEWID(),@itemRowGuid,'fd1caf80-7877-493a-9cd3-ff2ca861d1de',1,'60ff4b50-2227-4ad2-8950-f7cdab801d6a','8373de62-4f87-4ca4-b741-30da6491785f-1') fetch next from auth_cur into @itemRowGuid end close auth_cur

  

posted @ 2016-10-30 16:53  HongEgg  阅读(113)  评论(0编辑  收藏  举报