1、用一个表中的数据更新另一个表
UPDATE A SET A.column1=B.column1,A.column2=B.column2 FROM table1 A, table2 B WHERE A.columnkey = B.columnkey
2、选择数据库中重复的记录
id是关键字段,username是重复字段,select * from test where id not in (select max(t1.id) from test t1 group by t1.username)
3、复制表中数据到另外一个库中 (SQL2005)
DB1.A 复制到 DB2.A
---------------------------------------------
DB2.A不存在:SELECT * INTO db2.dbo.a FROM db1.dbo.a
DB2.A已存在:INSERT INTO db2.dbo.a SELECT * FROM db1.dbo.a