www.pryy.net > 在ExCEl里sql语句怎么写

在ExCEl里sql语句怎么写

Set conn = CreateObject("adodb.connection") conn.Open "provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source=" & ThisWorkbook.FullName Sql = " select * from [sheet1$a:v]" [a1].CopyFromRecordset conn.Execute...

例如简单的从sheet1表中的数据取到表二: Sub 简单查询() Set cn = CreateObject("adodb.connection") Set rs = CreateObject("adodb.recordset") cn.Open "provider=microsoft.jet.oledb.4.0;Extended Properties='Excel 8.0';data source=" & ...

请参阅 Excel如何通过SQL语句导入数据 http://jingyan.baidu.com/article/a65957f496ebac24e67f9b1a.html 注:Excel里没有像Access中有单独使用SQL的地方。只有在导入数据时有SQL语句输入的地方

ALT+F11,打开VBE,插入一个模块,把以下代码复制进去: Sub dosql(sql, a As Range) Dim Conn As Object Set Conn = CreateObject("ADODB.Connection") Set rst = CreateObject("ADODB.Recordset") PathStr = ThisWorkbook.FullName Select Cas...

Excel如何通过SQL语句导入数据_百度经验 http://jingyan.baidu.com/article/a65957f496ebac24e67f9b1a.html

SELECT 代号,数量 FROM 表 W WHERE 数量 IN (SELECT TOP 2 WITH TIES 数量 FROM 表 WHERE 代号=W.代号 ORDER BY 数量 DESC)

EXCEL2007或2007以上的版本可以使用

--Excel2003 INSERT INTO OPENROWSET('Microsoft.Jet.OleDb.4.0','Excel 8.0;DATABASE=D:\Excel文件名.xls','SELECT 字段1,字段2 FROM [Sheet1$]') SELECT top 20 字段1,字段2 FROM student --Excel2007 INSERT INTO OPENROWSET('Microsoft.Ace....

Set conn = CreateObject("adodb.connection") conn.Open "provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source=" & ThisWorkbook.FullName Sql = " select * from [sheet1$a:v]" [a1].CopyFromRecordset conn.Execute...

SQL SERVER 和EXCEL的数据导入导出 1、在SQL SERVER里查询Excel数据: -- ====================================================== SELECT * FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0', 'Data Source="c:\book1.xls";User ID=Admin;Passw...

网站地图

All rights reserved Powered by www.pryy.net

copyright ©right 2010-2021。
www.pryy.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com