-- 开启Ad Hoc Distributed Queries组件
--exec sp_configure 'show advanced options',1
--reconfigure
--exec sp_configure 'Ad Hoc Distributed Queries',1
--reconfigure
-- 关闭Ad Hoc Distributed Queries:
--exec sp_configure 'Ad Hoc Distributed Queries',0
--reconfigure
--exec sp_configure 'show advanced options',0
--reconfigure
--select * from OpenRowSet('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;HDR=Yes;IMEX=1;Database=c:\dl.xls', 'select * from [Sheet1$] where f1 is not null')
--select * from OpenRowSet('Microsoft.ACE.OLEDB.4.0', 'Excel 8.0;HDR=Yes;IMEX=1;Database=c:\dl.xls', 'select * from [Sheet1$]')
SELECT * INTO Temp_Upload1
-- 开启Ad Hoc Distributed Queries组件
--exec sp_configure 'show advanced options',1
--reconfigure
--exec sp_configure 'Ad Hoc Distributed Queries',1
--reconfigure
-- 关闭Ad Hoc Distributed Queries:
--exec sp_configure 'Ad Hoc Distributed Queries',0
--reconfigure
--exec sp_configure 'show advanced options',0
--reconfigure
--select * from OpenRowSet('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;HDR=Yes;IMEX=1;Database=c:\dl.xls', 'select * from [Sheet1$] where f1 is not null')
--select * from OpenRowSet('Microsoft.ACE.OLEDB.4.0', 'Excel 8.0;HDR=Yes;IMEX=1;Database=c:\dl.xls', 'select * from [Sheet1$]')
SELECT * INTO Temp_Upload1
FROM OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=c:\dl.xls',sheet1$)
--SELECT * INTO Temp_Upload1
--FROM OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=c:\dl.xls',sheet1$)
--delete from [Card].[dbo].[Temp_Upload1] where f1 is null
--delete from [Card].[dbo].[Temp_Upload1] where f1=''
--delete from [Card].[dbo].[Temp_Upload1] where f11 is null
--SELECT * FROM [Card].[dbo].[Temp_Upload1]
FROM OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=c:\dl.xls',sheet1$)
--SELECT * INTO Temp_Upload1
--FROM OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=c:\dl.xls',sheet1$)
--delete from [Card].[dbo].[Temp_Upload1] where f1 is null
--delete from [Card].[dbo].[Temp_Upload1] where f1=''
--delete from [Card].[dbo].[Temp_Upload1] where f11 is null
--SELECT * FROM [Card].[dbo].[Temp_Upload1]
本文介绍了如何在SQL Server中启用和禁用AdHocDistributedQueries组件,并提供了两个实例来展示其在读取Excel文件方面的应用。通过执行配置命令,用户可以控制查询的分布式执行,进而优化查询性能。
3594

被折叠的 条评论
为什么被折叠?



