0
点赞
收藏
分享

微信扫一扫

Excel文件导入SqlServer最简单方法!(超简单、超实用)

飞进科技 2022-05-24 阅读 90


-- 开启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]


举报

相关推荐

0 条评论