插入xxx和yyy之间的值

时间:2013-12-05 01:20:47

标签: sql sql-server insert range

尝试调整此查询,

将一系列行插入表中,获取错误消息,

  

“消息512,级别16,状态1,行1子查询返回的值超过1。当子查询跟随=,!=,<,< =,>,>时,不允许这样做。 =或当子查询用作表达式时。语句已终止。“

查询是否正确或是否还有其他我缺失的内容?

insert into VCCUS (IDCUST,AUDTDATE,AUDTTIME,AUDTUSER,AUDTORG,FININVPDF,WHSINVPDF,WHSDDKPDF,FININVACT,WHSINVACT,WHSDDKACT)
values ((select idcust from ARCUS where IDCUST between '7016' and '7077'),20131204,2073088,'admin','BRIDAT',0,0,0,2,0,0);

1 个答案:

答案 0 :(得分:1)

尝试此查询

 insert into VCCUS (IDCUST,AUDTDATE,AUDTTIME,AUDTUSER,AUDTORG,FININVPDF,WHSINVPDF,WHSDDKPDF,FININVACT,WHSINVACT,WHSDDKACT) 
    select t1.idcust, t2.*  from
    (
    select idcust from ARCUS 
    where IDCUST between '7016' and '7077'
    ) t1
     CROSS JOIN
    (
    SELECT 20131204 AUDTDATE ,2073088 AUDTTIME ,'admin' AUDTUSER,
    'BRIDAT' AUDTORG ,0 FININVPDF,0 WHSINVPDF,0 WHSDDKPDF,2 FININVACT,0 WHSINVACT,0 WHSDDKACT) t2