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
2
votes
0 answers

SSIS/Azure Data Factory or OPENROWSET/BULK INSERT in Azure SQL DB

I have a very simple csv file to import into Azure SQL DB table. Below are some properties: CSV file is of around 1 GB and stored on FTP server This need to be imported into a table and replaced on daily basis through a day-end job process My…
2
votes
1 answer

MS T-SQL 2008: Executing an openrowset sql string will not work

Running this code DECLARE @SQL VARCHAR(2500) = '''SELECT z.* from openrowset(''''SQLNCLI'''',''''Server=server;UID=user;PWD=pwd;'''', ''''SELECT distinct x.PackageName FROM [dw].[dbo].[dex] x JOIN [dw].dbo.log l on…
user259286
  • 977
  • 3
  • 18
  • 38
2
votes
1 answer

SQL Server 2017 microsoft-ace-oledb-12-0-x64-driver-freezing-using-open-rowset

I am using the openrowset feature to do a bulk insert SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','Excel 12.0; Database=\\mylocation_file_manager\',[Sheet1$]) this query works fine for a while but breaks unpredictably and only solution to…
2
votes
1 answer

How to avoid reading Decimal value as Float in Openrowset

In my excel, some values are like this 11.17 3.35 2.28 1.4 stored in General type. After importing the excel to database some values decimal places are completely getting changed. Example SELECT * into #temp FROM…
Pரதீப்
  • 91,748
  • 19
  • 131
  • 172
2
votes
1 answer

Alternative to Linked server, with same speed

I have a framework build with stored procedures that moves data 1 to 1 fra an OLTP to a BI staging area. It is generic, just tell it which table in the OLTP, and it builds the sql to move it. Problem is, it is build to use linked servers to the OLTP…
2
votes
0 answers

SQL server OpenRowset gives cannot create instance of OLEDB provider for linked server(null)

I am trying to call OPENROWSET command in SQL server 2012 to read data from xls excel file below is my code SET @sql = 'SELECT * FROM [' + @Query + '$]' Exec( 'select * FROM OPENROWSET( ''Microsoft.Jet.OLEDB.4.0'' ,''Excel 16.0;Database=' +…
Malo
  • 1,232
  • 2
  • 17
  • 28
2
votes
1 answer

Updating the table from stored procedure using openrowset

I am trying to update the column [IsUnique-check] in the table from stored procedure. I try following code. ALTER PROCEDURE spIsUnique @columnname NVARCHAR(MAX), @tablename NVARCHAR(MAX) AS BEGIN EXEC ('select IIf…
Awesome
  • 560
  • 2
  • 7
  • 18
2
votes
1 answer

SQL - OPENROWSET with variable instead of string path

I have a query that runs without a variable. It works as expected: INSERT INTO XMLwithOpenXML(XMLData, LoadedDateTime) SELECT CONVERT(XML, BulkColumn) AS BulkColumn, GETDATE() FROM OPENROWSET(BULK 'C:\xml\hamlet.xml', SINGLE_BLOB) AS x; However…
Jax Patočka
  • 23
  • 1
  • 3
2
votes
1 answer

error executing OPENROWSET (BULK) / Azure SQL Database

I am logged into an Azure SQL Database, using "Active Directory - Integrated" authentication wherein I supply my company domain credentials only; no password. I tried executing OPENROWSET on a .json file stored on my client (laptop): Select…
CarCrazyBen
  • 1,066
  • 5
  • 14
  • 37
2
votes
2 answers

Import structured XML file to SQL table

I'm trying to download and import a XML file to an SQL Table. The download is working perfectly and it generates the following XML file. GeoPers.xml
Ivan Pudic
  • 71
  • 1
  • 11
2
votes
3 answers

Accessing Oracle DB through SQL Server using OPENROWSET

I'm trying to access a large Oracle database through SQL Server using OPENROWSET in client-side Javascript, and not having much luck. Here are the particulars: A SQL Server view that accesses the Oracle database using OPENROWSET works perfectly,…
Ken Paul
  • 5,685
  • 2
  • 30
  • 33
2
votes
1 answer

SQL SERVER - OPENROWSET with filepath parameter

I have this SQL script tht work properly: INSERT INTO #XMLwithOpenXML(XMLData, LoadedDateTime) SELECT CONVERT(XML, BulkColumn) AS BulkColumn, GETDATE() FROM OPENROWSET(BULK 'C:\temp\test.wordpress.2017-05-22.xml', SINGLE_BLOB) AS x; SELECT @XML =…
DarioN1
  • 2,460
  • 7
  • 32
  • 67
2
votes
2 answers

deferred prepare could not be completed, 3 SQL Servers

I have 3 SQL Servers, and I'm getting strange behavior with OpenRowset. Given: Server 1 = 192.168.1.1, Server 2 = 192.168.1.2, Server 3 = 192.168.1.3, Server 4 = 192.168.1.4 SQL: SELECT a.* FROM OPENROWSET('SQLOLEDB', 'Data…
Aaron
  • 45
  • 1
  • 6
2
votes
2 answers

String concatenation in SQL doesn't work

I am wondering why the following doesn't work: INSERT INTO @Data2 (FileName,Field) SELECT @FileName as FileName, * FROM OPENROWSET(BULK '\\serverpath\' + @FileName , SINGLE_CLOB) AS Contents I tried also the second approach but with this one I…
nikogram
  • 71
  • 6
2
votes
1 answer

Encoding option CODEPAGE not working for OPENROWSET in MSSQL Server

I am trying to migrate data from Postgres database to SQL server. For this, I am exporting the Postgres data into JSON format, and the idea is to insert the data into my tables (I already have the schema from Postgres database imported into SQL…
iliyan tanev
  • 377
  • 2
  • 15