• 批量更新数据库的电子文件的版本问题


      declare @PGuid varchar(50)
      declare @Count int
      declare myCur2 Cursor LOCAL
      for( select ParentRowGuid ,Count(*) as count from [BIMPM_ModelData].[dbo].[EquipmentEFile] where ExtendName = 'rfa'
      group by ParentRowGuid HAVING count(ID) >1)
    
      open myCur2 
      fetch next from myCur2 into @PGuid,@Count
      while(@@FETCH_STATUS=0)
      begin
      ---select  * from [BIMPM_ModelData].[dbo].[EquipmentEFile] where ParentRowGuid = @PGuid and ExtendName = 'rfa' order by ID 
    
      update [BIMPM_ModelData].[dbo].[EquipmentEFile]
      set [FirstVersionRowGuid] = t2.RowGuid
      from (select top 1 ID,RowGuid from [BIMPM_ModelData].[dbo].[EquipmentEFile] where ParentRowGuid = @PGuid and ExtendName = 'rfa' order by id) t2
      where [BIMPM_ModelData].[dbo].[EquipmentEFile].ParentRowGuid = @PGuid
    
      update [BIMPM_ModelData].[dbo].[EquipmentEFile]
      set [IsMaxVersion] = 0
      from (select top 1 ID,RowGuid from [BIMPM_ModelData].[dbo].[EquipmentEFile] where ParentRowGuid = @PGuid and ExtendName = 'rfa' order by id desc) t2
      where [BIMPM_ModelData].[dbo].[EquipmentEFile].ParentRowGuid = @PGuid 
      and [BIMPM_ModelData].[dbo].[EquipmentEFile].[IsMaxVersion] = 1 
      AND [BIMPM_ModelData].[dbo].[EquipmentEFile].RowGuid <> t2.RowGuid
    
      fetch next from myCur2 into @PGuid,@Count
      end
      close myCur2
      
  • 相关阅读:
    shell test用法
    Makefile debug的经验
    Makefile 中:= ?= += =的区别
    Makefile中常用的函数
    Makefile选项CFLAGS,LDFLAGS,LIBS
    makefile双冒号规则
    makefile中的伪目标,强制目标和双冒号规则
    makefile 使用环境变量
    linux shell if语句使用方法
    linux的test命令
  • 原文地址:https://www.cnblogs.com/wangzuofei/p/13301158.html
Copyright © 2020-2023  润新知