在有自增主键列的表插入数据
--先打开IDENTITY_INSERT
set IDENTITY_INSERT mzy_time ON --表名称:mzy_time,AutoID为自增主键
--插入数据
insert into mzy_time ( AutoID,ampm ,doctor_code , req_order , yy_time , unit_code , charge_type , numbers , yy_status , que_order , win_no , flag , lockid , RequestId , CreateTime , IsReserver) SELECT * from mzy_time_b where yy_time>='2018/1/23 14:30:00' AND yy_time<='2018/1/23 17:30:00' and doctor_code='01607' AND unit_code='2120045' and AutoID NOT IN (select AutoID from mzy_time where yy_time>='2018/1/23 14:30:00' AND yy_time<='2018/1/23 17:30:00' AND doctor_code='01607' and unit_code='2120045')
--关闭IDENTITY_INSERT
SET IDENTITY_INSERT mzy_time OFF
感谢:http://blog.csdn.net/jnuyanfa/article/details/45279053
感谢给位大佬的无私