openrowset

The OLE DB provider “Microsoft.ACE.OLEDB.12.0” for linked server “(null)”

十年热恋 提交于 2019-11-26 22:43:48
问题 I'm trying to run the following statement but am receiving the error messages just below. I have researched answers to no end and none have worked for me. I'm running Office 365 (64bit). I have loaded the Microsoft Access Database Engine (64bit). This is in Visual Studio 2013 with SSDT as well as SQL Server 2012. I do not have access to changing environment or startup parameters to SQL Server. Any help is appreciated. SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.15.0', 'Excel 12.0;Database=C

Using a Variable in OPENROWSET Query

本秂侑毒 提交于 2019-11-26 17:44:19
I'm having trouble with this query: SELECT * FROM OPENROWSET( 'SQLNCLI', 'DRIVER={SQL Server};', 'EXEC dbo.sProc1 @ID = ' + @id ) Gives an error: Incorrect syntax near '+'. Anyone know why I'm getting this error? As suggested by Scott , you cannot use expressions in OPENROWSET .Try creating a dynamic sql to pass the parameters Declare @ID int Declare @sql nvarchar(max) Set @ID=1 Set @sql='SELECT * FROM OPENROWSET( ''SQLNCLI'', ''DRIVER={SQL Server};'', ''EXEC dbo.usp_SO @ID =' + convert(varchar(10),@ID) + ''')' -- Print @sql Exec(@sql) OPENROWSET requires string literals, not expressions. It's

SQL Server export to Excel with OPENROWSET

左心房为你撑大大i 提交于 2019-11-26 17:09:35
问题 I am successfully exporting to excel with the following statement: insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:\template.xls;', 'SELECT * FROM [SheetName$]') select * from myTable Is there any standard way to use this template specifying a new name for the excel sheet so that the template never gets written to or do I have to come up with some work-around? What's the best way to do this in people experience? 回答1: You'd have to use dynamic SQL. OPENROWSET etc only

How to create and populate a table in a single step as part of a CSV import operation?

ⅰ亾dé卋堺 提交于 2019-11-26 16:15:57
问题 I am looking for a quick-and-dirty way to import CSV files into SQL Server without having to create the table beforehand and define its columns . Each imported CSV would be imported into its own table. We are not concerned about data-type inferencing. The CSV vary in structure and layout, and all of them have many many columns, yet we are only concerned with a few of them: street addresses and zipcodes. We just want to get the CSV data into the SQL database quickly and extract the relevant

Cannot create an instance of OLE DB provider Microsoft.Jet.OLEDB.4.0 for linked server null

帅比萌擦擦* 提交于 2019-11-26 10:29:22
问题 I am trying to export from my Table data into Excel through T-SQL query. After little research I came up with this INSERT INTO OPENROWSET (\'Microsoft.Jet.OLEDB.4.0\', \'Excel 8.0;Database=G:\\Test.xls;\', \'SELECT * FROM [Sheet1$]\') SELECT * FROM dbo.products When I execute the above query am getting this error Msg 7302, Level 16, State 1, Line 7 Cannot create an instance of OLE DB provider \"Microsoft.Jet.OLEDB.4.0\" for linked server \"(null)\". So went through internet for solution, got

Using a Variable in OPENROWSET Query

*爱你&永不变心* 提交于 2019-11-26 05:35:05
问题 I\'m having trouble with this query: SELECT * FROM OPENROWSET( \'SQLNCLI\', \'DRIVER={SQL Server};\', \'EXEC dbo.sProc1 @ID = \' + @id ) Gives an error: Incorrect syntax near \'+\'. Anyone know why I\'m getting this error? 回答1: As suggested by Scott , you cannot use expressions in OPENROWSET .Try creating a dynamic sql to pass the parameters Declare @ID int Declare @sql nvarchar(max) Set @ID=1 Set @sql='SELECT * FROM OPENROWSET( ''SQLNCLI'', ''DRIVER={SQL Server};'', ''EXEC dbo.usp_SO @ID ='