--Required settings for the provider to work correctly as a linked serverEXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1 GO EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1
--#################################################################################################--Linked server Syntax for Excel with ACE 64 driver--#################################################################################################DECLARE @srvproduct nvarchar(256), @provider nvarchar(256), @location nvarchar(100), @provstr nvarchar(100), @catalog sysname, @sql varchar(1000)--add an excel spreadsheet as a linked server.SET @server = 'MyExcelACE'SET @srvproduct = ''SET @provider = 'Microsoft.ACE.OLEDB.12.0'set @provstr = 'Excel 12.0'SET @datasrc ='C:\Data\BlockGroups_2010\AKblockgroup.xls'EXEC sp_addlinkedserver @server,@srvproduct,@provider,@datasrc,NULL,@provstrEXEC dbo.sp_AddLinkedSrvLogin @server, FALSE, NULL, Admin, NULL--what spreadsheets (table equivilents are available?EXEC sp_tables_ex 'MyExcelACE'--you MUST know the name of the spreadsheet; --spreadsheet name has a dollar sign at the end of it!--I've personally never gor a spreadsheet that has a space in it--for example "Activity Data" =ActivityData$ never got [Activity Data$] or [Activity Data]$ to work--to work, so I end up editing the spreadsheet to remove spaces if that happens.select * from MyExcelACE...ActivityData$;select * from MyExcelACE...Sheet1$;