select into 和insert into select

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

 

posted @ 2017-05-17 08:58  夏风微凉  阅读(190)  评论(0编辑  收藏  举报