• Form数据迁移


    --------------------------------------添加linkserver---------------------------------------
    --EXEC master.dbo.sp_addlinkedserver @server = server', @srvproduct=N'SQL Server' 
    --EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'server',@useself=N'False',
    --@locallogin=NULL,@rmtuser=N'sa',@rmtpassword='XXXX'
    
    --------------------------------------动态表单迁移------------------------------------------
    DECLARE @form_Label NVARCHAR(30)
    DECLARE @form_Table NVARCHAR(30)
    DECLARE @strsql_InsertFormTable_Org NVARCHAR(200)
    DECLARE @strsql_InsertFormTable_Tag NVARCHAR(200)
    
    SET @form_Label='细胞学检查%'
    SET @form_Table=(select table_name from [server].[bio-d].dbo.forms where label like @form_Label)
    SET @strsql_InsertFormTable_Org='select * into '+@form_Table+' from [server].[bio-d].dbo.'+@form_Label
    SET @strsql_InsertFormTable_Tag='select * from '+@form_Table
    
    -- forms子表单结构表结构及数据
    exec(@strsql_InsertFormTable_Org)
    exec(@strsql_InsertFormTable_Tag)
    
    --检查添加是否成功
    select * from [server].[bio-d].dbo.forms where label like @form_Label
    select * from forms where label like @form_Label
    
    -- Forms表中记录的插入
    SET IDENTITY_INSERT forms ON
    insert into forms(id,label,name,table_name,type,collect_type,deleted,crt_time,crt_user,crt_user_name,upd_time,upd_user,upd_user_name,display_fields_in,bio_type) 
    select id,label,name,table_name,type,collect_type,deleted,crt_time,crt_user,crt_user_name,upd_time,upd_user,upd_user_name,display_fields_in,bio_type from  [server].[bio-d].dbo.forms where label like @form_Label
    SET IDENTITY_INSERT forms OFF
    
    -- 检查Form表中记录插入是否正确
    select * from [172.18.1.25].[bio-d].dbo.forms where label like @form_Label
    select * from forms where label like @form_Label
    
    -- fields字段中值的插入
    --select * from [server].[bio-d].dbo.fields where form_id in (select id from [server].[bio-d].dbo.forms where label like @form_Label )
    --select * from fields where form_id=67
    
    SET IDENTITY_INSERT fields ON
    insert into fields(id,label,name,form_id,data_type,required,deleted,child_form_id,field_name,crt_time,crt_user,crt_user_name,upd_time,upd_user,upd_user_name,validation,options,validation_msg,standalone_id,link_field_id,sort,default_value) 
    select id,label,name,form_id,data_type,required,deleted,child_form_id,field_name,crt_time,crt_user,crt_user_name,upd_time,upd_user,upd_user_name,validation,options,validation_msg,standalone_id,link_field_id,sort,default_value from [server].[bio-d].dbo.fields  where form_id in (select id from [server].[bio-d].dbo.forms where label like @form_Label )
    SET IDENTITY_INSERT fields OFF
    
    -- 验证插入是否正确
    select * from [server].[bio-d].dbo.fields where form_id in (select id from [server].[bio-d].dbo.forms where label like @form_Label )
    select * from fields where form_id in (select id from forms where label like @form_Label )
  • 相关阅读:
    并发编程学习笔记(15)----Executor框架的使用
    并发编程学习笔记(14)----ThreadPoolExecutor(线程池)的使用及原理
    并发编程学习笔记(13)----ConcurrentLinkedQueue(非阻塞队列)和BlockingQueue(阻塞队列)原理
    并发编程学习笔记(12)----Fork/Join框架
    并发编程学习笔记(11)----FutureTask的使用及实现
    并发编程学习笔记(10)----并发工具类CyclicBarrier、Semaphore和Exchanger类的使用和原理
    设计模式:代理模式
    设计模式:装饰模式
    设计模式:几大原则
    设计模式:策略模式(Strategy)
  • 原文地址:https://www.cnblogs.com/keepSmile/p/10406059.html
Copyright © 2020-2023  润新知