• 第一版无UUID版本

从临时表插入会员至member_info_svc表
insert into member_info_svc (
gh_no,chname,sex,birthday,tel,email,title,card_no,membership_type,enroll_date,expiry_date,id_no,
nationality,sub_type,vip_level,member_source,duty_code,language_code,member_department_code,id_type,
linkman_name,address,engname,card_password,insert_user,insert_date) select card_no,chname,sex,birthday,tel,email,title,card_no,membership_type,enroll_date,expiry_date,id_no,
nationality,sub_type,vip_level,member_source,duty_code,language_code,member_department_code,id_type,
chname,address,engname,'b1e79b6670e5fce34747b8c0a0e684beba9b8550','Shiji','2018-01-11'
from member where card_no not in (select card_no from member_info_svc); update member_info_svc set state='N' where insert_date='2018-01-11' and insert_user='Shiji' 将新导入的会员插入使用者表
insert into member_info_sub(parent_gh_no,sub_name,sex,title,birthday,nationality,address,tel,fax,email,remarks,create_date,position_code,language_code,valid_flag,exchange_flag,filter_flag,
main_flag,link_code,member_department_code,id_type,id_no,engname,office_tel,mobile,card_sn,card_no)
select gh_no,chname,sex,title,birthday,nationality,address,tel,fax,email,memo,enroll_date,duty_code,language_code,'1','1','0',
'1','0',member_department_code,id_type,id_no,engname,office_tel,office_tel,card_sn,card_no
from member_info_svc
where insert_user='Shiji' and insert_date='2018-01-11'
and not exists(select parent_gh_no from member_info_sub where parent_gh_no=member_info_svc.gh_no) 插入变更记录
-------------------------------------------------member_info_log-------------------------------------------------------
insert into member_card_modify_log( gh_no,oper_type,oper_date,operator_id,remark )
select gh_no,'N',getdate(),'admin','20180111批量导入'
from member_info_svc
where insert_user='Shiji'
and not exists (select gh_no from member_card_modify_log where gh_no=member_info_svc.gh_no)
  • 导入模板样式

card_no    chname    first_name    last_name    title    sex    birthday    email    linkman_tel    tel    office_tel    fax    address    zip    id_type    id_no    language_code    nationality    member_department_code    duty_code    membership_type    vip_level    sub_type    member_source    enroll_date    expiry_date    balance    sendtype_code    memo
960000016 徐新革 gexin xu Mr M 1985-12-31 CRO@SHIJINET.CN 12345678900 0001 123456789000000000 C CN DEA AA HZYHZZK 0 FOR HZ133001GM 2019-07-10 2059-07-10 200 CZ
  • 插入UUID
insert into member_info_svc(gh_no) values((select replace(NEWID(),'-','')))
  • 获取UUID
select (replace(NEWID(),'-',''))
  •  可生成UUID版本

--从临时表插入会员至member_info_svc表
insert into member_info_svc (
gh_no,chname,sex,birthday,tel,email,title,card_no,membership_type,enroll_date,expiry_date,id_no,
nationality,sub_type,vip_level,member_source,duty_code,language_code,member_department_code,id_type,
linkman_name,address,engname,card_password,insert_user,insert_date)
--生成UUID导入
select (replace(NEWID(),'-','')),chname,sex,birthday,tel,email,title,card_no,membership_type,enroll_date,expiry_date,id_no,
nationality,sub_type,vip_level,member_source,duty_code,language_code,member_department_code,id_type,
chname,address,engname,'b1e79b6670e5fce34747b8c0a0e684beba9b8550','Shiji','2018-01-11'
from member where card_no not in (select card_no from member_info_svc); update member_info_svc set state='N' where insert_date='2018-01-11' and insert_user='Shiji' --将新导入的会员插入使用者表
insert into member_info_sub(parent_gh_no,sub_name,sex,title,birthday,nationality,address,tel,fax,email,remarks,create_date,position_code,language_code,valid_flag,exchange_flag,filter_flag,
main_flag,link_code,member_department_code,id_type,id_no,engname,office_tel,mobile,card_sn,card_no)
select gh_no,chname,sex,title,birthday,nationality,address,tel,fax,email,memo,enroll_date,duty_code,language_code,'1','1','0',
'1','0',member_department_code,id_type,id_no,engname,office_tel,office_tel,card_sn,card_no
from member_info_svc
where insert_user='Shiji' and insert_date='2018-01-11'
and not exists(select parent_gh_no from member_info_sub where parent_gh_no=member_info_svc.gh_no) --插入变更记录
-------------------------------------------------member_info_log-------------------------------------------------------
insert into member_card_modify_log( gh_no,oper_type,oper_date,operator_id,remark )
select gh_no,'N',getdate(),'admin','20180111批量导入'
from member_info_svc
where insert_user='Shiji'
and not exists (select gh_no from member_card_modify_log where gh_no=member_info_svc.gh_no)
--想要将值插入到自动编号(或者说是标识列,IDENTITY)中去,需要设定 

SET IDENTITY_INSERT   member_info_svc ON

SET IDENTITY_INSERT   member_info_svc off

[昆仑会员卡系统]老会员数据导入 从临时表插入会员至member_info_svc表 SQL的更多相关文章

  1. oracle 老用户数据导入新建用户

    $sqlplus/nolog       #使用PLSQL进入oracleSQL>conn/as sysdba #进入sysdba权限CREATE DIRECTORY datadir1 AS ' ...

  2. ORACLE数据导入导出后新数据库中某些表添加操作报错[ORA-12899]

    由于项目需要,我在搭建了新的开发环境后,需要将之前环境中的ORACLE数据库导出,再导入到新的开发环境下.当导出导入完成后,使用数据库进行添加操作时 发现针对很多表的添加操作报错,具体报错原因描述为: ...

  3. 删除一个表中的重复数据同时保留第一次插入那一条以及sql优化

    业务:一个表中有很多数据(id为自增主键),在这些数据中有个别数据出现了重复的数据. 目标:需要把这些重复数据删除同时保留第一次插入的那一条数据,还要保持其它的数据不受影响. 解题过程: 第一步:查出 ...

  4. 【巨杉数据库SequoiaDB】巨杉Tech | 巨杉数据库数据高性能数据导入迁移实践

    SequoiaDB 一款自研金融级分布式数据库产品,支持标准SQL和分布式事务功能.支持复杂索引查询,兼容 MySQL.PGSQL.SparkSQL等SQL访问方式.SequoiaDB 在分布式存储功 ...

  5. 使用python将excel数据导入数据库

    使用python将excel数据导入数据库 因为需要对数据处理,将excel数据导入到数据库,记录一下过程. 使用到的库:xlrd 和 pymysql (如果需要写到excel可以使用xlwt) 直接 ...

  6. Excel数据导入PG库,字符串正则表达式

    1.Excel数据导入到PG库的某张表中:先将Excel文件转换为CSV格式,打开SQL Shell(psql),连接数据库(输入server,database,Port,username),然后再执 ...

  7. excel文件与txt文件互转,并且把excel里的数据导入到oracle中

    一.excel文件转换成txt文件的步骤 a.首先要把excel文件转换成txt文件 1.Excel另存为中已经包含了TXT格式,所以我们可以直接将Excel表格另存为TXT格式,但是最后的效果好像不 ...

  8. 使用 sqoop 将mysql数据导入到hdfs(import)

    Sqoop 将mysql 数据导入到hdfs(import) 1.创建mysql表 CREATE TABLE `sqoop_test` ( `id` ) DEFAULT NULL, `name` va ...

  9. 如何把EXCEL数据导入到SQL SERVER数据库中 (转)

    转:http://blog.csdn.net/jjp837661103/article/details/13509889 在我们完成一个项目开发之后,通常我们需要把客户的很多数据导入到数据库中,面对大 ...

随机推荐

  1. Java线程之间通讯(三)

    使用wait和notify方法实现了线程间的通讯,都是Object 类的方法,java所有的对象都提供了这两个方法 1.wait和notify必须配合synchronized使用 2.wait方法释放 ...

  2. java后台获取微信小程序openid

    一.jar包准备 1.在网盘下载 链接:https://pan.baidu.com/s/15HAAWOg_yn768g4s9IrcPg 提取码:hgj0 二.在pom文件中添加依赖 1.将外部的引入的 ...

  3. Node.js学习(第二章:node核心模块--fs)

    前言 Node.js中赋予了JavaScript很多在浏览器中没有的能力,譬如:文件读写,创建http服务器等等,今天我们就来看看在node中怎样用JavaScript进行文件的读写操作. 读文件 我 ...

  4. thinkphp5 使用PHPExcel 导入导出

    首先下载PHPExcel类.网上很多,自行下载. 然后把文件放到vendor文件里面. 一般引用vendor里面的类或者插件用vendor(); 里面加载的就是vendor文件,然后想要加载哪个文件, ...

  5. Swift 4 中的泛型

    作为Swift中最重要的特性之一,泛型使用起来很巧妙.很多人都不太能理解并使用泛型,特别是应用开发者.泛型最适合libraries, frameworks, and SDKs的开发.在这篇文章中,我将 ...

  6. 谈一谈做iOS播放器库开发所涉及的知识点

    在自己研究生毕业的时候,想着能找上一份做视频编解码的工作,可惜没有如愿,最后到了一家iOS游戏渠道公司去做游戏支付业务的SDK开发,我的iOS正式开发生涯就这么开始了. 在那家iOS游戏渠道没做上一年 ...

  7. 聊Java中的任务调度的实现方法及比较

    前言 任务调度是指基于给定时间点,给定时间间隔或者给定执行次数自动执行任务.本文由浅入深介绍四种任务调度的 Java 实现: Timer ScheduledExecutor 开源工具包 Quartz ...

  8. php 执行大量sql语句 MySQL server has gone away

    php 设置超时时间单位秒 set_time_limit(3600);   php 设置内存限制ini_set('memory_limit', '1024M');   mysql服务端接收到的包的大小 ...

  9. CentOS 7.x 配置静态 IP 并启用

    centos 7.x 配置静态 IP 并启用 0 问题由来 通过查询本机的IP,发现本机并没有有效IP: [pan@localhost ~]$ ip addr 所以,我们需要设置本机的静态IP,并启用 ...

  10. Linux常用时间函数

    time()函数: NAME time - get time in seconds SYNOPSIS #include <time.h> time_t time(time_t *tloc) ...