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
Filter by
Sorted by
Tagged with
1 vote
1 answer
899 views

Is there any easy way to import multiple .txt files to SQL server?

I am trying to import 24 .txt files to the server but I have limited privileges. All files start with the same characters, but '*' this masking cannot be used for this query. I use below script. ...
ilham's user avatar
  • 33
1 vote
2 answers
3k views

counting rows in csv file before bulk insert , non empty file check

I have a csv file and am trying to run bulk insert. But before I do bulk insert I want to make sure this file is not having only the column header row. It should have at least 1 row of data. select ...
Mohammad Shahbaz's user avatar
0 votes
0 answers
190 views

Output of Stored procedure to Temp table at runtime

I have a procedure CREATE PROCEDURE getdata AS SELECT * FROM mytable Now i want insert the output into a temporary table. I can do like INSERT INTO #TempTable EXEC getdata But i have to create a ...
Avinash's user avatar
  • 533
0 votes
1 answer
613 views

Stored Procedure results in Excel

I have a requirement to provide the results of my analysis in different sheets under one excel file. Currently i'm manually copying and pasting the results into excel (10 sheets). How I can use the ...
Avinash's user avatar
  • 533
0 votes
0 answers
829 views

Bulk loading (BULK Insert) with multiple amounts of whitespace

I'm trying to import a TXT file using the BULK INSERT function using SQL Server. The data in the text file appears as such: XDB XDB_XTABNMSP FLAGS NUMBER 6 XDB ...
Depth of Field's user avatar
0 votes
1 answer
545 views

T-SQL procedure call using OPENROWSET

I have two queries. This first query creates a .csv file in a C:\... folder with no errors: INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0','Text;Database=C:\Temp\TEMP_SQL_FOLDER\T-SQL to csv\;HDR=...
CLS's user avatar
  • 13
0 votes
0 answers
40 views

Error while exporting SQL Server data via OPENROWSET feature

I am using below query to export SQL Server table data to Excel, but I am getting a syntax error as shown below. Incorrect syntax near ' '. Code: INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0',...
Mohana Krishnan A R's user avatar
1 vote
1 answer
2k views

How to upload images to a SQL database in Azure?

I've seen some queries to upload the images from a file, but I get this error message: Cannot bulk load because the file could not be opened I went to the properties>security option of the file to ...
S Cabrera's user avatar
1 vote
0 answers
2k views

OPENROWSET From SQL to Oracle

i'm trying to connect from sql server to oracle server with OPENROWSET for fetch data. this is my query: SELECT a.* FROM OPENROWSET(N'OraOLEDB.Oracle', N'Data Source=Myip:Port/dbname';'User Id=user';...
AhmadR3zA's user avatar
2 votes
1 answer
579 views

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 ...
Gunni Saggu's user avatar
0 votes
1 answer
147 views

SSMS :: import XML file from OSM and parse nodes

I'm trying to import an .osm file (which is basically an XML file) into SQL Server. If you want you can try the code by downloading a copy of the file I'm importing form here (just click "Export"). ...
Francesco Mantovani's user avatar
0 votes
1 answer
899 views

When using openrowset how can I avoid inserting blank lines at the end of an excel sheet

I am using openrowset to extract values from an excel sheet. The openrowset works fine but the only problem is that it also extracts blank lines at the end of the excel sheet which then results in ...
Shumba Soft's user avatar
0 votes
2 answers
180 views

SET - EXECUTE in TSQL with passed variable

I'm working with an OPENROWSET (BULK...) insert where I'm inserting a small XML file into a table before ultimately shredding and transforming it. The following works just fine (many thanks to other ...
trying2figureitout's user avatar
0 votes
1 answer
862 views

How to bulk import many Word documents into SQL Server database table

I need to import ~50,000 Word documents (.doc and .docx) from a single directory into a SQL Server 2016 database table so that I can use full text indexing and then search the documents' contents. ...
Philip Stratford's user avatar
0 votes
2 answers
2k views

Loading 50GB CSV File Azure Blob to Azure SQL DB in Less time- Performance

I am loading 50GB CSV file From Azure Blob to Azure SQL DB using OPENROWSET. It takes 7 hours to load this file. Can you please help me with possible ways to reduce this time?
SCK's user avatar
  • 1
0 votes
2 answers
2k views

Import EXCEL data to SQL Server without data conversion

I am trying to insert excel data into sql server tables. Each column should be imported with the exact same format that the user wrote in the source Excel. I am using following query to fetch data ...
AcAnanth's user avatar
  • 775
1 vote
1 answer
2k views

SQL Server: Select data from tab delimited file with OPENROWSET and BULK returns empty result

I want to query data from a tab delimited file using SQL Server and OPENROWSET. I have the following sample source file: FirstName LastName EMail Marny Haney [email protected] ...
Takeshi's user avatar
  • 139
1 vote
0 answers
1k views

Access Denied when using Access ODBC Driver

When using Access 2016 ODBC driver to open an excel document, I get Access Denied in ProcMon. I only get this on error a file on a remote file share. SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.16.0'...
alexander7567's user avatar
1 vote
1 answer
502 views

"OPENROWSET" function keeps Executing without any Output

I am trying to SELECT from an Excel file through SSMS. I am using the OPENROWSET Function to Select the Excel file into SSMS I have already done everything I have found on Google Including to turn ...
Vignesh Murali's user avatar
0 votes
3 answers
1k views

Dynamic SQL: OPENROWSET with @param and INSERT into @Table

I'm trying to insert into a @table parameter using OPENROWSET with a @param in a loop. I've adapted code from: This Answer, which demonstrates using Dynamic SQL to insert the parameter. Code: ...
Adam's user avatar
  • 1,991
0 votes
0 answers
310 views

Extra quotes from exporting from SQL Server to CSV

I am getting extra double quotes (") when exporting to CSV using "Insert into OpenRowSet" command from a SQL Server stored procedure (this is part of a C# Visual Studio Core2 automation program, so I ...
Danimal111's user avatar
  • 2,022
12 votes
1 answer
645 views

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', ...
Pரதீப்'s user avatar
1 vote
1 answer
10k views

Bad or inaccessible location specified in external data source "(null)"

I'm having difficulty accessing data in a text file via OPENROWSET. The file is saved locally. I'm raising the error which seems to be related to the location of the file but I'm really confused as to ...
emalcolmb's user avatar
  • 1,633
0 votes
2 answers
257 views

How to union records of two stored procedures without knowing columns

I have 2 stored procedures which returns same but unknown columns. I need to write a proc to combine results from both stored procedures. I tried OPENROWSET but problem is to provide the connection ...
Maroof Raini's user avatar
0 votes
1 answer
6k views

The OLE DB provider "MSDASQL" for linked server "(null)" reported an error. The provider did not give any information about the error

I need to import multiple files with a varying number of columns into SQL Server through a script. I am trying to use OPENROWSET for this. I have done the following. Installed driver on the client ...
Santhosh C.V.'s user avatar
1 vote
3 answers
371 views

SQL Server - OPENROWSET Server name error using parameters

I'm having trouble with this query...Any idea how to declare variables and make it visible to OPENROWSET query? DECLARE @SERVERNM VARCHAR; SET @SERVERNM = (SELECT(CAST(CONNECTIONPROPERTY('...
Gabriel Franco's user avatar
0 votes
1 answer
594 views

Getting some NULL headers from Excel file using OpenRowSet

I'm trying to get the headers of my Excel file. When I'm using this code: SELECT TOP 1 * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0 Xml;HDR=NO;Database=C:\myfolder\myfile.xlsx;', 'SELECT ...
Alan's user avatar
  • 139
1 vote
0 answers
215 views

Insert Image into Azure database as varbinary(max) using SSMS on local PC

I am doing some testing to see if I can use SSRS with an Azure database to create a simple report. I want to include a signature image at the bottom of the report that I am storing as a blob in the ...
dickiebow's user avatar
  • 106
1 vote
1 answer
1k views

OPENROWSET SSMS to import excel file

I am trying to use the OPENROWSET command in sql server management studio to query excel files. SELECT * INTO #Temp FROM OPENROWSET('Microsoft.ACE.OLEDB.16.0', 'Excel 12.0;...
Hunderfert's user avatar
0 votes
1 answer
491 views

Query result to xlsx and send mail in SQL Server

There is a procedure in which an Excel file is created, the result of the selection is saved in it. This file is attached to the letter and sent by mail. But the problem is that the file is created ...
noanother's user avatar
0 votes
1 answer
129 views

Read n qty rows of delimited txt file in Python

I have a large txt file that I want to read in python. It's tab delimited. I want to be able to read the headers as well. I saw this stackoverflow site but it doesn't show how to both designate the n ...
Scott Davis's user avatar
0 votes
1 answer
1k views

OPENROWSET error if Excel column has more than 8224 characters

I used OPENROWSET to import Excel file. It worked if the column <= 8224 characters. My code is as below: SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0 Xml;HDR=YES;IMEX=1;...
Hoang Tran's user avatar
0 votes
2 answers
64 views

How do I fix my problem with executing code with OPENROWSET?

I want to open an Excel dataset with openrowset function, but an error keeps on showing up: begin declare @pathname NVARCHAR(max) set @pathname = N'\\{DATAPATH} select @pathname ...
jadas08's user avatar
2 votes
1 answer
789 views

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 ...
Pரதீப்'s user avatar
1 vote
0 answers
364 views

Using openrowset in SQL Server 2014

I have the below SQL statement that I was using to get data from a stored procedure into a temp table SET @sql = N'SELECT * INTO #CustomTable3HTML FROM ...
SP1's user avatar
  • 1,182
0 votes
0 answers
110 views

Using stored procedure in openrowset throws login_mapping error

Because I need to fill a view with dynamic data, I wrote a stored procedure to collect the data and use select from OPENROWSET('SQLNCLI','server=....;trusted_connection=yes','EXEC Stored_Procedure') ...
K.J. Kok's user avatar
0 votes
0 answers
912 views

Convert PDF File to binary encoded string and store into SQL Server without using BULK

I need to read a PDF file and convert that into Binary string into SQL server but I cannot use BULK operation , I cant not use the below code any alternative to BULK DECLARE @pdf VARBINARY(MAX) ...
Subrat Srivastwa's user avatar
0 votes
2 answers
956 views

I have a problem inserting more than 255 chars per column into an Excel file using INSERT INTO OPENROWSET from SQL Server

I am getting an error while exporting data from SQL Server to an already created .xlsx file using openrowset. It works fine most of times, but when the data comes in of the field as a large string, ...
Tripurari Yadav's user avatar
1 vote
1 answer
1k views

.csv file import using sql bulkload or openrowset for missing column data

.I have a csv file. The data is given below, ___________________________________________________________ StateName | City | Score1 | Score2 | ________________|...
Ashish Bagade's user avatar
3 votes
1 answer
2k views

Pass file by @parameter to OPENROWSET BULK json query, SQL 2016

In sql 2016 This works: SELECT @JSONFileData = BulkColumn FROM OPENROWSET (BULK 'C:\Temp\Students_2015.json', SINGLE_CLOB) as JSON This does not: SELECT @JSONFileData = BulkColumn FROM OPENROWSET ...
Kevin Russell's user avatar
0 votes
1 answer
508 views

OPENROWSET cannot find files with special characters in file name

I have to import documents as a whole into an SQL Server table. I have a table with all filenames. I loop through the table and use the following dynamic SQL to load the data. SET @sqlUpdate = '...
Peter Zilz's user avatar
1 vote
0 answers
44 views

XML Data load into SQL Server Special XML Format

Okay so I am trying to load a large complex XML file into multiple tables. I am trying to drill down to one of the smallest nodes but then can't access the node above it. use [ChaseDB] DECLARE @x ...
Chase Visa's user avatar
1 vote
0 answers
1k views

Command to read/import .dbf files from local system into SQL Server 2016 64 bit

I am trying to import .dbf files into SQL Server 2016 64bit. For this I installed Microsoft Visual FoxPro. Below setup works for 32bit version of SQL Server but not to 64bit. I also tried changing the ...
username hidden's user avatar
0 votes
1 answer
85 views

Import data from Excel into SQL

I am trying to import data from Excel into SQL. I had already done this before one year with OPENROWSET. SELECT A.surname FROM OPENROWSET ('Microsoft.ACE.OLEDB.12.0','Excel 12.0;Database=C:\temp\...
Tasos's user avatar
  • 1
0 votes
1 answer
995 views

OPENXML not returning data, no error message

I've never worked with XML before but have been tasked to import a document into a SQL Server table. As a test, I'm been using an example I found online and, for now, I'm only trying to retrieve a ...
Corey C.'s user avatar
0 votes
0 answers
43 views

Import XML data with into SQL Server with Romanian charset

I have a problem encoding a XML file from Romania. The file is in utf-8 and has the following content (only an excerpt) <?xml version = "1.0" encoding "utf-8"?> <EXPORT> <ORDER>...
Frank M.'s user avatar
1 vote
1 answer
4k views

How to pass path to Bulk in OPENROWSET command

I have a XML file. I would like to run a query on it. I am using OPENROWSET(BULK ... , SINGLE_BLOB) like below code. DECLARE @XML XML SELECT @XML = CAST( c1 AS XML) FROM ...
Ardalan Shahgholi's user avatar
0 votes
0 answers
329 views

sql server openrowset importing json files performance

I have around 400GB of json files (150MB each) that I'm importing to sqlserver with 6 files importing in parallel using ssis(machine has 6 CPUs). It's taking around 4 hours only to import the data ...
DC07's user avatar
  • 303
0 votes
1 answer
692 views

SQL Server OPENROWSET Numeric vales changes as int

I have a problem in my SQL Server 2008 R2 OPENROWSET to read the csv file. It automatically converts the numeric values as int while read from the csv file. I have a csv file with column ColumnA ...
rAm's user avatar
  • 309
0 votes
0 answers
203 views

Excel inserts no data using OPENROWSET when logged in as any account but my local account

I am trying to export data to Excel from SQL Server via a c# winforms application. The application is running on a windows domain environment. Here is the query: string exportQuery = @"INSERT INTO ...
David Folksman's user avatar

1 2
3
4 5
8