1:复制表结构
select * into 数据库1.dbo.table1 from 数据库2.dbo.table2 where (1=2)
2:复制表(包括结构和数据)
select * into 数据库1.dbo.table1 from 数据库2.dbo.table2 where (1=1)
3.从一个表中分组统计信息,插入新表中
select productcode ,count(*) as quantity into tempquantity from inventorylocation where grade='3' and del='0' and booknumber like '02%' and productcode like '9787%' and locationnumber is not null group by productcode
4 ,把一个表中的数据更新到另外一个表中是sql。
update inventoryinfo set inventoryinfo.quantity = tempquantity.quantity
from inventoryinfo inner join tempquantity
on inventoryinfo.productcode = tempquantity.productcode where grade='3' and inventoryinfo.quantity>tempquantity.quantity
本文介绍了使用SQL进行数据迁移的方法,包括仅复制表结构、同时复制结构与数据、从源表分组统计并插入新表,以及如何更新目标表中的数据。
1万+

被折叠的 条评论
为什么被折叠?



