|
发表于 2020-4-1 23:15:01
|
显示全部楼层
eqname 是从哪里取到的?
从另外的表里吗?
假如是从表teqname中取得的
select faultbit,faultname,eqname
into mytable
from (select eqname from teqname) a,
(select 0 as faultbit,过载 as faultname union
select 1,跑偏 union
select 2,'' union
select 3,'' union
select 4,'' union
select 5,'' union
select 6,'' union
select 7,'' ) b
--如果是从其他地方取得的,或者有一定的规律
那就
create table mytable
(
faultbit int,
faultname varchar(10),
eqname varchar(10)
)
declare @eqname
set @eqname = '值' --赋值
while (条件)
begin
insert inot mytable(faultbit,faultname,eqname)
select faultbit,faultname,@eqname as eqname
from
(select 0 as faultbit,过载 as faultname union
select 1,跑偏 union
select 2,'' union
select 3,'' union
select 4,'' union
select 5,'' union
select 6,'' union
select 7,'' )b
--这里写为@eqname 赋新值的语句
end |
|