Questions tagged [openrowset]

OPENROWSET is a T-SQL function that can be used in Microsoft SQL Server to read remote data from an OLE DB data source. It also supports bulk operations that can read data from a file and return it as a rowset.

OPENROWSET is a T-SQL (Transact-SQL) function that can be used to read remote data from many sources, for example an OLE DB data source or a file from the file system.

This method is an alternative to accessing tables in a linked server and is a one-time, ad hoc method of connecting and accessing remote data by using OLE DB. For more frequent references to OLE DB data sources, use linked servers instead.

OPENROWSET also supports bulk operations through a built-in BULK provider that enables data from a file to be read and returned as a rowset.

The OPENROWSET function can be referenced in the FROM clause of a query as if it were a table name. The OPENROWSET function can also be referenced as the target table of an INSERT, UPDATE, or DELETE statement, subject to the capabilities of the OLE DB provider. Although the query might return multiple result sets, OPENROWSET returns only the first one.

354 questions
46
votes
25 answers

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

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).…
Steven Kanberg
  • 6,078
  • 2
  • 16
  • 35
36
votes
4 answers

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

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;', …
Pரதீப்
  • 91,748
  • 19
  • 131
  • 172
36
votes
6 answers

Using a Variable in OPENROWSET Query

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?
Control Freak
  • 12,965
  • 30
  • 94
  • 145
31
votes
6 answers

INSERT INTO from two different server database

I am trying to copy the data of testdabse.invoice table to basecampdev.invoice table. testdabse is a local database while basecampdev is in the server. My query for copying data to another table doesn't work, it says Invalid object name…
fiberOptics
  • 6,955
  • 25
  • 70
  • 105
22
votes
10 answers

How to resolve "Could not find installable ISAM." error for OLE DB provider "Microsoft.ACE.OLEDB.12.0"

I am trying to import data from Excel 2007 (.xlsx) files into SQL Server 2008 using a T-SQL OpenRowset() command with the "Microsoft.ACE.OLEDB.12.0" OLE DB provider, and I'm getting a persistent "Could not find installable ISAM" error. All hardware…
Martin_W
  • 1,582
  • 1
  • 19
  • 24
18
votes
7 answers

Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)"

Having an interesting issue. I'm reading from an excel file on a server via an OpenRowset in Sql2005. I've run the query a number of times without any problems. I've just gone out for a quick meeting and suddenly I get the error "Cannot initialize…
StevenMcD
  • 17,262
  • 11
  • 42
  • 54
18
votes
3 answers

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

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…
Tim
  • 8,669
  • 31
  • 105
  • 183
15
votes
2 answers

T-SQL: issue with string concat

I have a set of audio files with names GreenLine1.mp3, GreenLine2.mp3 e.t.c. I'm going to write them into a table as BLOB (I use MS SQL Server'08), here's my sql request: DECLARE @aud AS VARBINARY(MAX) DECLARE @num AS INT -- Load the audio…
Ilya Blokh
  • 11,923
  • 11
  • 52
  • 84
15
votes
1 answer

How to use a variable in Openrowset command

I am trying to use a variable filepath in a SQL Openrowset command. I'm aware that it can't explicitly accept a variable and that I need to make use of dynamic SQL. What currently works - SELECT @file_stream = CAST(bulkcolumn AS…
bjjrolls
  • 529
  • 4
  • 8
  • 21
13
votes
2 answers

openrowset for excel: can we skip several rows?

I will use the following sql to read data from excel, but sometimes I need to skip first several rows. e.g the real data begins from line 5, so I need to skip the first 4 rows, is that doable? SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', …
Daniel Wu
  • 5,853
  • 12
  • 42
  • 93
13
votes
4 answers

SQL Server: Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)"

I am trying to run the following query: SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=C:\Somefile.xlsx', 'SELECT * FROM [Sheet$]') But I get this error: Cannot initialize the data source object of OLE DB provider…
S L
  • 409
  • 2
  • 6
  • 15
12
votes
1 answer

Data Truncation issue while importing excel from Azure Blob storage to Sql Server

I'm trying to import the below excel file present in the azure blob storage into sql server EXCEL File Query SELECT * FROM OPENROWSET( BULK 'container/testfile.xlsx', DATA_SOURCE = 'ExternalSrcImport', …
Pரதீப்
  • 91,748
  • 19
  • 131
  • 172
11
votes
3 answers

Using OPENROWSET to dynamically retrieve SP results when SP contains # temp tables

My Scenario I'm working on a database which will contain many details from various Stored Procedures in different databases across the entire server. The information I'm attempting to gather now is, "What does the SP output?" In searching I've found…
Zok Wobblefotz
  • 353
  • 1
  • 3
  • 10
11
votes
4 answers

OPENROWSET or OPENDATASOURCE Example to get Data from .xlsx or .csv file on file system of Remote Server

There are plenty of examples around showing how to use OPENROWSET and OPENDATASOURCE to open queries against tables on remote SQL servers, and to get data from files on other servers. Unfortunately, none of them tell me how to do the specific thing…
Bruce Long
  • 713
  • 3
  • 9
  • 28
9
votes
3 answers

Convert scientific notation to float when using OpenRowSet to import a .CSV file

I am using openrowset to import a csv file into SQL Server. One of the columns in the csv file contains numbers in scientific notation (1.08E+05) and the column in the table it is being inserted By default it is importing the value as 1 and…
amarcy
  • 1,485
  • 2
  • 19
  • 28
1
2 3
23 24