加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

SQLServer复制表结构复制表数据

发布时间:2020-12-12 13:35:53 所属栏目:MsSql教程 来源:网络整理
导读: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,cou

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读