Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sp_configure 'show advanced options', 1;
- RECONFIGURE;
- GO
- sp_configure 'Ad Hoc Distributed Queries', 1;
- RECONFIGURE;
- GO
- USE ImportFromExcel;
- GO
- SELECT * INTO Data_dq
- FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0',
- 'Data Source=D:DesktopData.xlsx;Extended Properties=Excel 12.0')...[Data$];
- GO
- DECLARE @RC int
- DECLARE @server nvarchar(128)
- DECLARE @srvproduct nvarchar(128)
- DECLARE @provider nvarchar(128)
- DECLARE @datasrc nvarchar(4000)
- DECLARE @location nvarchar(4000)
- DECLARE @provstr nvarchar(4000)
- DECLARE @catalog nvarchar(128)
- -- Set parameter values
- SET @server = 'EXCELLINK'
- SET @srvproduct = 'Excel'
- SET @provider = 'Microsoft.ACE.OLEDB.12.0'
- SET @datasrc = 'D:DesktopData.xlsx'
- SET @provstr = 'Excel 12.0'
- EXEC @RC = [master].[dbo].[sp_addlinkedserver] @server, @srvproduct,
- @provider,
- @datasrc, @location, @provstr, @catalog
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement