Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. sp_configure 'show advanced options', 1;
  2. RECONFIGURE;
  3. GO
  4. sp_configure 'Ad Hoc Distributed Queries', 1;
  5. RECONFIGURE;
  6. GO
  7.  
  8. USE ImportFromExcel;
  9. GO
  10. SELECT * INTO Data_dq
  11. FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0',
  12. 'Data Source=D:DesktopData.xlsx;Extended Properties=Excel 12.0')...[Data$];
  13. GO
  14.  
  15. DECLARE @RC int
  16.  
  17. DECLARE @server nvarchar(128)
  18. DECLARE @srvproduct nvarchar(128)
  19. DECLARE @provider nvarchar(128)
  20. DECLARE @datasrc nvarchar(4000)
  21. DECLARE @location nvarchar(4000)
  22. DECLARE @provstr nvarchar(4000)
  23. DECLARE @catalog nvarchar(128)
  24.  
  25. -- Set parameter values
  26. SET @server = 'EXCELLINK'
  27. SET @srvproduct = 'Excel'
  28. SET @provider = 'Microsoft.ACE.OLEDB.12.0'
  29. SET @datasrc = 'D:DesktopData.xlsx'
  30. SET @provstr = 'Excel 12.0'
  31.  
  32. EXEC @RC = [master].[dbo].[sp_addlinkedserver] @server, @srvproduct,
  33. @provider,
  34. @datasrc, @location, @provstr, @catalog
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement