这种语句在access中怎么写INSERT into report_his (reptype,repdate,repfn) (select(100分)

C

cxz9

Unregistered / Unconfirmed
GUEST, unregistred user!
这种语句在access中怎么写
SQL server中可以的
INSERT into report_his (reptype,repdate,repfn) (select 'FORMA格式一','2002-12-31','16!02!01-FP01A00102' union select '发票格式一','2002-12-31','16!17!25-FP01A00102')
 
access insert 好像不支持 union,
这两个select用union有用吗?!
 
access 不支持 union
也不支持 嵌套Sql语句。
 
>这两个select用union有用吗?!
当然有用了,那样一次可以插入多条记录。
 详见
delphi+sql server--数据库大容量数据的加入和导出(上百万数据的加入与导出)的提速问题!诚找高手探讨!!!
http://www.delphibbs.com/delphibbs/dispq.asp?lid=853039
 
不支持!
 
access中很多sql语句都不支持,没办法
 
access中好像是不支持union的
试试其它办法吧
 
union分两次插入不就完了
 
那样不是效率很低呀。
 
这只是个例子我那儿要插入很多记录
 
可以的话,我又学了一招.
 
写成这样可以通过
INSERT into report_his (reptype,repdate,repfn)
values('FORMA格式一','2002-12-31','16!02!01-FP01A00102'),
('发票格式一','2002-12-31','16!17!25-FP01A00102')
 
刚试过,Access中,以下语句没有语法错误,但结果不对。
(select top 2 * from gzlm) union (select top 1 * from gzlm)
查询出来的记录数决定于前一个Select语句,也就是只有两条,
但是后一句select若有语法错误会被检测到。不知道为什么
 
to cxz9:
误会了! 我说的是union在这里没有用,access 不支持的 :)

to pnljh:
你的意思是不是应该出3条 --
用 (select top 2 * from gzlm) union all (select top 1 * from gzlm)
 
INSERT into report_his (reptype,repdate,repfn)
values ('FORMA格式一','2002-12-31','16!02!01-FP01A00102'),('发票格式一','2002-12-31','16!17!25-FP01A00102');

这句不能通过的,在),(那儿说少个;号,也就是说这句有语法错误
 
你在一个query里写
INSERT into report_his (reptype,repdate,repfn)
values ('FORMA格式一','2002-12-31','16!02!01-FP01A00102')
INSERT into report_his (reptype,repdate,repfn)
values('发票格式一','2002-12-31','16!17!25-FP01A00102');
然后query.execsql;
就可以了
 
access 支持union,坎套sql用该用 (select * from xx) as yy这种形式,也支持
insert into ...
看你对sql挺熟的,你自己试试吧:)
 
这么久了,结帐
 
顶部