sql server 中用 insert into......select ...... union插入多行同样的记录,为什么只能插入一条?求解
createtabledamo1--创建damo1表(numberintidentity(1,1),dnamevarchar(10)notnull,dsexchar(2)...
create table damo1 --创建damo1表
(
number int identity(1,1),
dname varchar(10) not null,
dsex char(2) ,
dage int
)
insert into damo1 --damo1插入多行重复的记录
select '张三','男',18 union
select '张三','男',18 union
select '张三','男',18 union
select '张三','男',18 union
select '张三','男',18 union
select '张三','男',18 展开
(
number int identity(1,1),
dname varchar(10) not null,
dsex char(2) ,
dage int
)
insert into damo1 --damo1插入多行重复的记录
select '张三','男',18 union
select '张三','男',18 union
select '张三','男',18 union
select '张三','男',18 union
select '张三','男',18 union
select '张三','男',18 展开
展开全部
union 会自动过滤掉重复行的,要用union all来合并
insert into ....select .... from talbe
union all
select .... from table2
insert into damo1 --damo1插入多行重复的记录
select '张三','男',18 union all
select '张三','男',18 union all
select '张三','男',18 union all
select '张三','男',18 union all
select '张三','男',18 union all
select '张三','男',18
insert into ....select .... from talbe
union all
select .... from table2
insert into damo1 --damo1插入多行重复的记录
select '张三','男',18 union all
select '张三','男',18 union all
select '张三','男',18 union all
select '张三','男',18 union all
select '张三','男',18 union all
select '张三','男',18
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询