1、查:
select * from openrowset(
'Microsoft.Jet.OLEDB.4.0',
'Excel 5.0;Database=d:/excel.xls;User ID=;Password=;',
'select * from [sheet1$]'
2、修改:(注意要先把ad hoc distributed queries 设为1)
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
update openrowset(
'Microsoft.Jet.OLEDB.4.0',
'Excel 5.0;Database=d:/excel.xls;User ID=;Password=;',
'select * from [sheet1$]'
) set a='d' where a='c'
3、插:
方法一:insert openrowset(
'Microsoft.Jet.OLEDB.4.0',
'Excel 5.0;Database=d:/excel.xls;User ID=;Password=;',
'select * from [sheet1$]'
) select 'aaa'
方法二:insert into openrowset(
'Microsoft.Jet.OLEDB.4.0',
'Excel 5.0;Database=d:/excel.xls;User ID=;Password=;',
'select * from [sheet1$]'
) values ('王进')