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

来源:互联网 发布:java坐标点的构造函数 编辑:程序博客网 时间:2024/05/16 15:35

-- 开启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_Upload1FROM   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]
原创粉丝点击