--开启sql server 操作Execl服务
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
------操作实例-----------------------------
select * from OpenDataSource ( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="D:\table.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1]
(
TableName,
FieldName
)
insert into OpenDataSource ( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="D:\table.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]
(
TableName,
FieldName
)
select a.[name],b.[name]
from syscolumns as a --in (select id from sysobjects where xtype = 'U' And [Name] = 'Products')
left join dbo.systypes AS b ON a.xtype = b.xusertype
where a.id =object_id('Products')
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17140602/viewspace-582327/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/17140602/viewspace-582327/