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
8
votes
1 answer

XML parsing error: why is semicolon expected?

I'm a newbie struggling with trying to import XML from an external third-party into SQL Server. I tried this SQL with the XML below and it pukes with "XML parsing: line 10, character 81, semicolon expected" in the middle of the Name tag - WHY?? Why…
Sheri
  • 91
  • 1
  • 1
  • 3
8
votes
2 answers

how to use openrowset to execute a stored procedure with parameters

I'm creating a stored procedure which gets some parameters and in turn these parameters are sent to another stored procedure which I'm calling from openrowset but I'm getting some syntax errors. CREATE PROCEDURE UpdatePrevFYConfigData -- Add…
Viniez
  • 93
  • 1
  • 1
  • 6
7
votes
1 answer

Connect to a webservice from SQL

SQL Server is able to open excel sheets (xlsx), access databases (mdb) and other data streams using data providers (e.g. JET, ACE) and OPENROWSET. Are there similar facilities to extract data from a remote webservice ? Using OPENROWSET and providing…
Wadih M.
  • 12,810
  • 7
  • 47
  • 57
7
votes
1 answer

OpenRowSet, OpenQuery, OpenDataSource - which is better in terms of performance

This can be a debatable answer, but I'm looking for the case where a local Excel file needs to be exported to a local SQL Server 2008' table. Has anyone ever had the chance to check execution time to compare OpenRowSet/OpenQuery/OpenDataSource for a…
Loser Coder
  • 2,338
  • 8
  • 42
  • 66
7
votes
1 answer

image data types are invalid for local variables (using openrowset cannot make it work)

Using Sql server 2005 I need to call a stored procedure that has many parameters and one which is an image column that is used for word document. I cannot change database since it's not under my control. I cannot seem to set a result of an…
user9969
  • 15,632
  • 39
  • 107
  • 175
6
votes
5 answers

OpenRowSet command in TSQL is returning NULLS

Been investigating for a while now and keep hitting a brick wall. I am importing from xls files into temp tables via the OpenRowset command. Now I have a problem where I’m trying to import a certain column has a range values but the most common are…
StevenMcD
  • 17,262
  • 11
  • 42
  • 54
5
votes
8 answers

How to export SSIS to Microsoft Excel without additional software?

This question is long winded because I have been updating the question over a very long time trying to get SSIS to properly export Excel data. I managed to solve this issue, although not correctly. Aside from someone providing a correct answer,…
Zachary Scott
  • 20,968
  • 35
  • 123
  • 205
5
votes
1 answer

Import from csv (into different columns) via Openrowset and Microsoft.ACE.OLEDB.12.0

I want to clarify how I could import data from .csv into table with 3 columns (see CR Ranking.csv below). My query: select * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','Text;Database=C:\Work\;HDR=Yes;', 'SELECT * FROM [CR Ranking.csv]'); Outputs…
zmische
  • 809
  • 3
  • 13
  • 23
5
votes
4 answers

Update to Openrowset SQL SERVER 2008

I'm trying to do an UPDATE action to a remote table from a local query. Obviously i know it should be with an OPENROWSET but i don't know how to do it. I know you can Insert to an OPENROWSET doing something like this: set @cadsql =…
JGutierrezC
  • 4,398
  • 5
  • 25
  • 42
4
votes
3 answers

SQL Server export to Excel with OPENROWSET

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…
JohnIdol
  • 48,899
  • 61
  • 158
  • 242
4
votes
1 answer

Not all rows are imported from Excel file using OPENROWSET in SQL Server

I have a Excel table with 47 columns and 14K rows. I import this data to SQL Server with OPENROWSET: INSERT INTO dbo.my_table SELECT * FROM OPENROWSET ( 'Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;HDR=Yes;Database=C:\ExcelFile.xlsx', 'SELECT…
JohnyL
  • 6,894
  • 3
  • 22
  • 41
4
votes
1 answer

OPENROWSET fails with "Invalid authorization specification"

I am trying to use OPENROWSET in SQL Server 2008 SP1: SELECT * FROM OPENROWSET( 'SQLOLEDB', 'Data Source=hydrogen;User ID=scratch;Password=scratch;', 'select * from users') OLE DB Provider: SQLOLEDB Connection String: Data…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
4
votes
1 answer

sql server openrowset to read huge xml files in one step

It's my first post ever... and I really need help on this one so any one who has some knowlege on the subject - please help! What I need to do is to read an xml file into sql server data tables. I was looking over and over for solutions to this one…
AirPoland
  • 53
  • 3
4
votes
1 answer

The metadata could not be determined because every code path results in an error; see previous errors for some of these

I am migrating from SQL Server 2005 to SQL Server 2014 and one of the queries stopped working in SQL Server 2014: select * from openrowset ('SQLOLEDB','Server=(local);TRUSTED_CONNECTION=YES;',' exec [MyDatabase].[dbo].[MyTable]') I get the…
Val K
  • 301
  • 3
  • 9
  • 22
4
votes
6 answers

'Microsoft.ACE.OLEDB.12.0' 64x Sql Server and 86x Office?

The error: OLE DB provider 'Microsoft.ACE.OLEDB.12.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode. And the answers I'm seeing is a conflict between 64 bit Sql Server and 32…
Chris Hayes
  • 3,876
  • 7
  • 42
  • 72
1
2
3
23 24