码迷,mamicode.com
首页 > 其他好文 > 详细

select into 和insert into select

时间:2017-05-17 10:09:50      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:http   insert   rom   logs   select   primary   插入   技术分享   9.png   

select into:

  创建测试语句

create database MyDemoTest
go
use MyDemoTest
go
create table A
(
    a int primary key,
    b int,
)
go
insert into A values(1,1),
(2,2),
(3,3)

  执行核心语句:

select a,b into B from A

  执行结果:

技术分享

  由这个结果我们可以知道,B表在插入的时候并不存在

 insert into select:

 

drop table B
create table B
(
    a int primary key,
    b int,
)
go
insert into B(a,b) select a,b from A

技术分享

 

select into 和insert into select

标签:http   insert   rom   logs   select   primary   插入   技术分享   9.png   

原文地址:http://www.cnblogs.com/student-note/p/6865745.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!