insert into DB1.table select distinct * from DB2.table
1、说明:复制表(只复制结构,源表名:a 新表名:b) (Access可用) 法一:select * into b from a where 1 <>1 法二:select top 0 * into b from a 2、说明:拷贝表(拷贝数据,源表名:a 目标表名:b) (Access可用) insert into b(a, b, c) select d,e,f from a; 3、说明:跨数据库之间表的拷贝(具体数据使用绝对路径) (Access可用) insert into b(a, b, c) select d,e,f from b in ‘具体数据库’ where 条件 例子:..from b in '"&Server.MapPath(".")&"\data.mdb" &"' where..
insert into DB2.dbo.table ( select * from DB1.dbo.table except select * from DB2.dbo.table)
insert into db2.dbo.Table select * from db1.dbo.Table where id not in(select id from db2.dbo.Table)
insert into DB2.dbo.table ( select * from DB1.dbo.table except select * from DB2.dbo.table)
insert into DB1.table select distinct * from DB2.table
dts sql:select * from t1 t where not exists(select 1 from t2 where id=t.id)
insert into db2.dbo.Table select * from db1.dbo.Table where id not in(select id from db2.dbo.Table)
--SQL2005 insert into DB2.dbo.[table] select * from ( select * from DB1.dbo.[table] except select * from DB2.dbo.[table] ) as t--SQL2000:如果表有主键IDinsert into DB2.dbo.[table] select * from DB1.dbo.[table] t where not exists( select 1 from DB2.dbo.[table] where id=t.id)
insert into DB2.dbo.table select ( select * from DB1.dbo.table except select * from DB2.dbo.table) tv修改下我上面写的
--如果没有自增字段的话,是这样。 insert db2..tb select * from db1..tb a where not exists(select 1 from db2..tb where 不重复字段1=a.不重复字段1 and 不重复字段2=a.不重复字段2)--依次类推 --如果有自增字段的话,在字段列表里不加这个字段
insert into DB1.table select distinct * from DB2.table
法一:select * into b from a where 1 <>1
法二:select top 0 * into b from a 2、说明:拷贝表(拷贝数据,源表名:a 目标表名:b) (Access可用)
insert into b(a, b, c) select d,e,f from a; 3、说明:跨数据库之间表的拷贝(具体数据使用绝对路径) (Access可用)
insert into b(a, b, c) select d,e,f from b in ‘具体数据库’ where 条件
例子:..from b in '"&Server.MapPath(".")&"\data.mdb" &"' where..
(
select * from DB1.dbo.table
except
select * from DB2.dbo.table)
insert into db2.dbo.Table
select * from db1.dbo.Table
where id not in(select id from db2.dbo.Table)
(
select * from DB1.dbo.table
except
select * from DB2.dbo.table)
sql:select * from t1 t where not exists(select 1 from t2 where id=t.id)
insert into db2.dbo.Table
select * from db1.dbo.Table
where id not in(select id from db2.dbo.Table)
insert into DB2.dbo.[table]
select *
from (
select * from DB1.dbo.[table]
except
select * from DB2.dbo.[table]
) as t--SQL2000:如果表有主键IDinsert into DB2.dbo.[table]
select * from DB1.dbo.[table] t
where not exists(
select 1
from DB2.dbo.[table]
where id=t.id)
select
(
select * from DB1.dbo.table
except
select * from DB2.dbo.table) tv修改下我上面写的
insert db2..tb select * from db1..tb a where
not exists(select 1 from db2..tb where
不重复字段1=a.不重复字段1 and 不重复字段2=a.不重复字段2)--依次类推
--如果有自增字段的话,在字段列表里不加这个字段