如何才能在一个Access数据表同时插入多行?在SQL Sever里可以用以下语句,请问在Access中应该怎么做?谢谢
insert into MyTable(ID , MyCharField, MyFoatField)select 1, ' ' , 0 union all select 2, ' ' , 0 union all select 3, ' ' , 0 union all select 4, ' ' , 0 union all select 5, ' ' , 0 union all select 6, ' ' , 0 union all select 7, ' ' , 0 union all select 8, ' ' , 0 union all select 9, ' ' , 0 union all select 10, ' ' , 0 union all select 11, ' ' , 0 union all select 12, ' ' , 0 union all select 13, ' ' , 0 union all select 14, ' ' , 0
insert into MyTable(ID , MyCharField, MyFoatField)select 1, ' ' , 0 union all select 2, ' ' , 0 union all select 3, ' ' , 0 union all select 4, ' ' , 0 union all select 5, ' ' , 0 union all select 6, ' ' , 0 union all select 7, ' ' , 0 union all select 8, ' ' , 0 union all select 9, ' ' , 0 union all select 10, ' ' , 0 union all select 11, ' ' , 0 union all select 12, ' ' , 0 union all select 13, ' ' , 0 union all select 14, ' ' , 0
解决方案 »
- 用VB判断MYSQL数据库名称是否存在,大侠们给段源码吧!
- 我怎樣才可以把VB程式移植到OFFICE VBA
- 菜鸟请教高手!
- ------如何禁止REG文件被打开,被编辑---------
- 下面这段代码为什么在win98下面不正常?---在线等
- 一个算法(扫描),一个函数(DoEvents)请教~~~分数不在多,乃在于用于恰倒好处~~~~
- 动态加载dll,如果有窗口则使用CallWindowProc执行dll中的函数,可我现在是ActiveX,怎么办
- To所有精通打包的朋友!
- 如何确定某个标题在页面中的位置?
- vb 请问在VB中如何连接BerkeleyDB嵌入式数据库,最好能给点实例,谢谢
- vb+sqlserver数据备份与数据恢复的问题
- 我覆盖安装了系统win2000 pro sp4 安装了vb6.0打开原来的工程运行说找不到工程或库??
select * from SQLServer表
或用BCPmaster..xp_cmdshell'bcp "serv-htjs.dbo.serv_user" out "c:\db3.mdb" -c -q -S"." -U"sa" -P"sa"'上面的区别主要是:OpenRowSet需要mdb和表存在,BCP会在不存在的时候生成该mdb3、从Access向SQLServer写数据:有了上面的基础,这个就很简单了insert into SQLServer表 select * from
OpenRowSet('microsoft.jet.oledb.4.0',';database=c:\db2.mdb','select * from Accee表')
楼主还真是令人汗阿,直接用
insert into tbl(fld1,fld2) values(...)
就好啦既然SQLServer能用的SQL,ACCESS也可以的
tryinsert into MyTable(ID , MyCharField, MyFoatField)
select * from
(
select 1, ' ' , 0
union all select 2, ' ' , 0
union all select 3, ' ' , 0
union all select 4, ' ' , 0
union all select 5, ' ' , 0
union all select 6, ' ' , 0
union all select 7, ' ' , 0
union all select 8, ' ' , 0
union all select 9, ' ' , 0
union all select 10, ' ' , 0
union all select 11, ' ' , 0
union all select 12, ' ' , 0
union all select 13, ' ' , 0
union all select 14, ' ' , 0
)
select * from
(
select 1 as id, ' ' as MyCharField, 0 as MyFoatField
union all select 2, ' ' , 0
union all select 3, ' ' , 0
union all select 4, ' ' , 0
union all select 5, ' ' , 0
union all select 6, ' ' , 0
union all select 7, ' ' , 0
union all select 8, ' ' , 0
union all select 9, ' ' , 0
union all select 10, ' ' , 0
union all select 11, ' ' , 0
union all select 12, ' ' , 0
union all select 13, ' ' , 0
union all select 14, ' ' , 0
)
不知道你的具体情况,如果联合查询不是来自表中的数据,这样写是不是很累,好象没必要吧?还不如在程序中用循环插入吧?