zoukankan      html  css  js  c++  java
  • 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 )
  • 相关阅读:
    170815、redis3.0安装配置
    170814、Java使用gzip压缩文件、还原文件
    170811、Java获取jdk系统环境变量
    170810、spring+springmvc+Interceptor+jwt+redis实现sso单点登录
    加密概述
    软件测试入门第02天:基础理论知识
    软件测试入门第01天:综述
    【心路历程】永远热泪盈眶
    Linux部署Django:报错 nohup: ignoring input and appending output to ‘nohup.out’
    【WEB】jQuery 判断复选框是否选中
  • 原文地址:https://www.cnblogs.com/keepSmile/p/10406059.html
Copyright © 2011-2022 走看看