作业里 insert tb FROM OPENROWSET('MSDASQL', 'DRIVER={SQL Server};SERVER=seattle1;UID=sa;PWD=MyPass', pubs.dbo.authors) where ....
偶只是举个简单例子而已. 你要是有N个表的话, 就做N次呀.(当然你还得根据各表之间的关系, 决定哪个先删除.)比如:insert into DB2.dbo.table_a(col1, col2....) select col1, col2...from DB1.dbo.table_a where colN = 'DEL'....DELETE A FROM table_a A inner join DB2.dbo.table_a B on a.col1 = b.col1 -- 假设在两表中col1是PK ....
你是2005的话就特别简单用OUTPUT增强 delete A output deleted.* into table2 feom table1 A where ...
insert tb FROM OPENROWSET('MSDASQL',
'DRIVER={SQL Server};SERVER=seattle1;UID=sa;PWD=MyPass',
pubs.dbo.authors)
where ....
select col1, col2...from DB1.dbo.table_a
where colN = 'DEL'....DELETE A FROM table_a A
inner join DB2.dbo.table_a B on a.col1 = b.col1 -- 假设在两表中col1是PK
....
你是2005的话就特别简单用OUTPUT增强
delete A
output
deleted.*
into table2
feom table1 A
where ...
DB2.dbo.table_a
就是代表2个数据库里面的table_a表的意思了?
原来这样啊
dbo--所有者
table_a--表名