博客园 首页 联系 订阅 管理

insert into tableb..bb(b1,b2,b3) select a1,a2,a3 from tablea..aa

 

insert into 数据库1.a(id,name...)select id,name...from 数据库2.b

insert into tableb(b1,b2,b3) select a1,a2,a3 from[wjjj].[dbo].[fbase]

insert into tableb(b1,b2,b3) select a1,a2,a3 from[数据库2名].[dbo].[表]

 

实例

 

create database Testa
use Testa
create table Tablea
(
 id int primary key identity(1,1) not null,
 userName varchar(50) not null,
 pwd varchar(50) not null,
 age int not null
)
create database TestB
use TestB
create table Tableb
(
 id int primary key identity(1,1) not null,
 ageb int not null,
 pass varchar(50) not null
)


insert into Tableb(ageb,pass) select age,pwd from Testa.dbo.Tablea

insert into Tablea(age,pwd) select ageb,pass from TestB.dbo.Tableb

posted on 2011-11-18 16:59  $蔷  阅读(6543)  评论(1编辑  收藏  举报