1.把某个数据库的某个表的某行数据 拷贝插入到另一个数据库的某个表里面
insert into TestDB1.dbo.table1
([Name]
,[sex]
,[age])
select
[Name]
,[sex]
,[age]
from TestDB2.dbo.table12
where Id=666
2.假设一个表里面存储了多个项目的信息,每个项目编号又有多条记录,我要取每个项目最新的一条记录,用group by
select a.* from ProjectInfo a,
(select MAX(ID)as outID from ProjectInfo group by SN)as b
where a.ID = b.outID ;