SQL高级应用之同服务器上复制表到另一数据库中

网络编程 2021-07-05 13:42www.168986.cn编程入门
项目需求将数据库Whir_ezMall_Full中的表Whir_Member的数据迁移到数据库Whir_ezMall_Full_c中的Whir_Member表,已存在的ID记录则不插入

SQL语句

代码如下:

INSERT INTO Whir_ezMall_Full_c..Whir_Member(MemberID, LevelID, Aount, MemberPWD, Email, Integral, MemberName, MemberStatus, Sex, Birthday, Area, Adress, ZipCode, Tel, Mobile, SaveQuestion, SaveAnswer, CreateData, LastLoginData, ImgUrl, LimitIntegral, IntegralBeginTime, IntegralEndTime, memberType, BankType, BankRegion, BankAddress, BankAount, BankName, IsQQ)
SELECT MemberID, LevelID, Aount, MemberPWD, Email, Integral, MemberName, MemberStatus, Sex, Birthday, Area, Adress, ZipCode, Tel, Mobile, SaveQuestion, SaveAnswer, CreateData, LastLoginData, ImgUrl, LimitIntegral, IntegralBeginTime, IntegralEndTime, memberType, BankType, BankRegion, BankAddress, BankAount, BankName, IsQQ FROM Whir_ezMall_Full..Whir_Member
WHERE Whir_ezMall_Full..Whir_Member.MemberID NOT IN (SELECT MemberID FROM Whir_Member)

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by