365 questions
0
votes
0
answers
111
views
Export data from SQL Server to Excel with OpenRowSet
I'm trying to export data from SQL Server to Excel with OpenRowSet.
The data does get exported to the Excel sheet datosOtraManera, BUT formulas are not automatically recalculated because Excel doesn't ...
0
votes
1
answer
45
views
How can I return an empty result instead of error 13807 when querying a path that might not exist with OPENROWSET?
I have a Synapse SQL Serverless query as follows
SELECT *
FROM OPENROWSET
(
BULK 'mytestpath/*/*',
DATA_SOURCE = 'LocalDataLake',
FORMAT = 'Parquet'
)
WITH(
Foo INT,
Bar INT
) X
The ...
0
votes
1
answer
121
views
Reading an Excel in SQL through OpenDataSource (OpenRowSet): rows order?
I have T-SQL code for SQL Server 2012 to read an Excel file into a temp table. I do this using OPENDATASOURCE:
INSERT INTO #MyTable (id, F1)
SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS id, F1
...
0
votes
1
answer
95
views
openrowset doesn't work for XML file in Azure SQL database
I'm using the Azure SQL Database and need to read an XML file from the Azure Storage Account. I've used openrowset but got the error:
"File '2025/02/01/FUL01of01.xml' cannot be opened because it ...
0
votes
0
answers
79
views
SQL that works fine when read in OPENROWSET fails when the same code is a string in T-SQL
I'm writing some basic testing code to try out a couple of ways to address UPDATE performance. I made 10000 lines of UPDATES and saved that to a textfile. It's about 3 MB in total. An example of the ...
0
votes
0
answers
105
views
Read large binary file in chunks in Microsoft SQL Server
Is there any functionality that allows reading binary file in chunks?
Currenty I am using the following query to read binary files:
SELECT
image_data.BulkColumn
FROM
OPENROWSET(BULK 'C:\bigfile', ...
0
votes
0
answers
119
views
SSRS use a dynamic SQL query with parameter
I have been facing a problem for several days, I have not found a solution on the various forums and in the documentation that I have read
I need to create a SQL query that allows me to retrieve data ...
0
votes
0
answers
58
views
Error when inserting special characters such as Ñ and accents á, é, í, ó, ú. using BULK OPENROWSET from python in a linux server
I am having problems inserting information into a table in my SQLSERVER 2008 database from my python project deploy in a linux server using OPENROWSET BULK and even though the CSV file generates ...
0
votes
1
answer
574
views
Communication between Azure Synapse and Azure SQL Server via Script in Azure Serverless SQL pool
Are we able to use Azure Synapse sql pool (T-SQL querying) with complexe queries to combine data query from datalake to read parquet files (with the openrowset) and an other source like Azure sql ...
1
vote
0
answers
212
views
OPENROWSET read old xls file
I have a problem on SQL SERVER 2022. When I want to select data from an XLSX file, everything works perfectly, but when I want to select data from an older XLS file, I get this message:
The Microsoft ...
0
votes
1
answer
105
views
Error when inserting special characters such as Ñ and accents á, é, í, ó, ú. using BULK OPENROWSET from python
I am having problems inserting information into a table in my SQLSERVER 2008 database from my python project using OPENROWSET BULK and even though the CSV file generates special characters such as Ñ, ...
0
votes
0
answers
280
views
Create new Excel Sheet with SQL Server OPENROWSET
I need to write data to a new Excel sheet in an existing Excel file, with T-SQL.
I need to use ACE OLEDB and OPENROWSET statement.
Usually, I write from a table to an existing Excel sheet, with:
...
0
votes
0
answers
205
views
Getting 'Attribute "FIELDQUOTE" could not be specified for this type' when using .xml format file for a T-SQL OPENROWSET BULK Query
I am getting an 'Attribute "FIELDQUOTE" could not be specified for this type.' that has me pulling my hair out trying to perform an OPENROWSET query to work so I can bulk import records from ...
1
vote
1
answer
481
views
Query Amazon S3 file via OPENROWSET with SQL Server 2022
I'm trying to query a parquet file uploaded to Amazon S3 from SQL Server 2022 using OPENROWSET.
I can confirm that I can access the S3 bucket with those access keys because I ran a python script to ...
0
votes
0
answers
213
views
Error Message When Executing Using Direct Query to execute a stored procedure with parameters in Power BI
I am trying to run a SQL Server stored procedure in Power BI that has parameters and I am getting this error:
DataSource.Error: Microsoft SQL: Named Pipes Provider: Could not open a connection to SQL ...
0
votes
1
answer
939
views
OPENROWSET Bulk Load multiple JSON files from Azure Blob Storage
I am trying to read from an Azure Blob Storage containing multiple nested-JSON files, eg:
0000001.json
0000002.json
0000003.json
...
I created an External Data Source.
So far, I managed to ...
0
votes
0
answers
122
views
How to load complex JSON data into SQL Server table where there are multiple tables
This is my JSON data:
[
{
"meta": {
"disclaimer": "Data downloaded for practice",
"terms": "https://open.fda.gov/terms/",
...
0
votes
2
answers
444
views
OPENROWSET only accepting VARCHAR/NVARCHAR for a Date column in a CSV, not DATE (Synapse Serverless)
A CSV file is being dumped into an Azure Datalake. When I try to make an OPENROWSET view in Synapse Serverless, the date column is only working as a VARCHAR/NVARCHAR, not any sort of DATE.
Here's the ...
1
vote
2
answers
754
views
Best way to automate processing of daily XML files into SQL database
I need to process a frequent flow of XML files into a SQL Server database on an automated basis. I have a sample XML file and have gotten as far as being able to process the data via SQL query using ...
1
vote
3
answers
4k
views
Want to use OPENROWSET to open Local XML file in SQL Server
I'm doing some testing in SSMS with various XML files on my LOCAL disk (in my C:\Temp folder), but I am connected to a remote test SQL Server. Is there any way to do something like this:
DECLARE @xml ...
0
votes
1
answer
2k
views
Openrowset doesn't execute in SQL Server
I am trying to take data from an Excel sheet and store it into SQL Server 2019 through the Openrowset statement. First I asked to enable 'ad hoc distributed queries' and 'show Advanced Options', which ...
0
votes
1
answer
830
views
Azure Synapse SQL pool not identifying csv headers using OPENROWSET
I am trying to read a csv from an Azure Synapse Serverless SQL Pool, but it is not able to read the headers of the csv properly, and that in none of the following attempts:
The csv is:
test_col1,...
0
votes
2
answers
1k
views
Grant a login SELECT on some Synapse Serverless Views, but not ability to run OPENROWSET on *entire* Datalake
For SQL Server based login in Synapse Serverless, as soon as I run these two things:
use master
GO
Create Login JustTest WITH PASSWORD='Whatever'
use somedatabase
Create User JustTest from login ...
0
votes
0
answers
447
views
SQL Server OPENROWSET Msg 7302 Cannot create an instance of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)"
I am trying to create a procedure that import an excel sheet in my SQL Server database with SSMS (I am admin).
I have no problem when I do the import manually; my excel file is closed and I can modify ...
0
votes
0
answers
223
views
How to use the OPENROWSET without setting Ad Hoc Distributed Queries to true?
I’ve been trying to use OPENROWSET function in SQL to upload data from an Excel file to SQL Server. According to my research, Ad Hoc Distributed Queries must be set to true. Unfortunately, I cannot ...
0
votes
0
answers
115
views
Classic ASP SQL openrowset query with UNC is being denied because of permissions when it previously worked
I have an sql query that retrieves data from a network .csv file using OpenRowSet:
select * from openrowset ('Microsoft.ACE.OLEDB.12.0', 'Text;Database=\\1.1.1.1\C$\temp', 'Select * from test.csv')
1....
0
votes
1
answer
124
views
Dynamic query to read XML file using OpenRowSet executes manually but not with SP_Execute
This gives me a valid query which works:
:setvar StreamsLocalFolder 'C:\inetpub\wwwroot\app'
DECLARE @sql VARCHAR(MAX)
SET @sql = 'SELECT MyFile.BulkColumn FROM OPENROWSET(BULK ''' +
$(...
0
votes
1
answer
220
views
Synapse Analytics query fails when arguments for WHERE-IN operator contains colon like ('asdf:asdf')
I am using Synapse Analytics to query a simple .csv file containing a single column.
Here is the query I'm using:
SELECT a.[Product Code]
FROM OPENROWSET(
BULK ('https://<mystorage>....
0
votes
0
answers
281
views
SQL Server Access to Disk C
Is there any way to grant my SQL Authenticated SQL Server Account a Full Control access to Disk C? I have an Excel File uploader that opens .xlsx files to read the data and INSERT it into the database....
0
votes
0
answers
435
views
Change the collation of fields when using OpenRowSet
I have this task where I need to use OpenRowset to insert data into a table and then use that table further for specific calculation (using views).
This is the code for OpenRowSet that I am using:
...
-1
votes
2
answers
2k
views
how to set bulk_options in openrowset to read file from Azure blob storage?
I have an Azure SQL database and would like to read a csv file from Azure blob storage (gen 2) with openrowset. However, the output lacks proper formatting, as rows and columns are not separated.
In ...
0
votes
1
answer
61
views
XML data to SQL tables, difficulty gettting child node data
I have an xml file that I am loading into SQL. I have no problem getting the xml file loaded and the top level nodes into a sql table. I am having difficulty reaching the next level child node.
...
0
votes
1
answer
208
views
Allowing @ symbol in connection string for OPENROWSET from Synapse
I am trying to connect to Synapse SQL database external tables (which access databricks lakehouse tables) from SQL server using openrowset
This works:
select * from
OPENROWSET(
'SQLNCLI',
'...
0
votes
0
answers
52
views
Create ##temp table and insert the rows to an existing table only wherever the columns match
The flow of what I want to achieve is as per the below steps:
I have an Excel file (which has dynamic columns), however certain columns are static and don't change, however their position in the file ...
0
votes
1
answer
669
views
Escape characters in .csv for Azure Synapse seems to dissapear?
I have .csv file that looks like this:
"ID", "Name", "Extra Info"
"1", "John", "{\"Event\": \"Click\", \"Button Name\&...
0
votes
1
answer
729
views
Filestream and using bulk insert via OPENROWSET gives File could not be opened. Operating system error code 50(The request is not supported.)
I felt in love with the filestream capacities of SQL Server giving the possibility to see only files and skip the complexity of hierarchies.
When I import a xml file in a table using openrowset I get ...
1
vote
2
answers
943
views
How to list all parquet files in s3 bucket folder via OPENROWSET (SQL Server)?
I have a bucket (AWS) in a folder with 3 PARQUET files that are the same and have different names:
I'm trying to create an EXTERNAL TABLE with the code below:
CREATE EXTERNAL TABLE tb_Test
(
coluna_1 ...
-1
votes
3
answers
3k
views
I am getting an error Incorrect syntax near 'OPENROWSET'. while using openrowset function on dedicated SQL Pool
First I added a credential:
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'Mumbai@1234';
GO
CREATE DATABASE SCOPED CREDENTIAL credanubhav -- this name must match the container path, start with https and ...
0
votes
2
answers
2k
views
Executing an OPENROWSET on azure synapse result in a 'Resolving CosmosDB path has failed with error 'Secret is not base64 encoded.''
I am deploying to an azure synapse environment queries using sqlcmd to serverless pool.
The environment contains an SQL database that my deploying account has access to.
I am creating first the ...
0
votes
0
answers
101
views
How to allow all users to run this SQL query?
Some context: I am trying to upload data from Comcast into our database. Comcast sends the data in a macro-enabled workbook with file extension ".xlsm" which is disgusting. To circumvent ...
0
votes
1
answer
63
views
How can I use with inside apply in sql server? I know another solution without apply. but can we do with outer apply? if 'yes' then how?
Can we use with inside any apply in the SQL server?
For traversing all nodes in the XML file I am trying to use outer apply so I can traverse in one go.
DECLARE @XML AS XML, @hDoc AS INT, @SQL ...
0
votes
1
answer
901
views
Openrowset but select only specific columns from file
Hoping there is a way to do this, I want to use open row set to select only specific columns from a file that has many more than what I need. I'm trying to do the below but getting an error on the ...
0
votes
1
answer
3k
views
Getting "7302 - Cannot Create an instance of OLE DB" Error after ACE/ODBC Driver update
We're running SQL Server 2014 with all the latest service packs. Our users heavily rely on OPENROWSET for importing XLSX, CSV and TXT files. Example:
SELECT * FROM OPENROWSET ('MSDASQL','DRIVER={...
1
vote
0
answers
84
views
I have an Excel file with a table and additional text (comments) on the same sheet. I want to extract ONLY the table. How can I do this in SQL?
So, I am using query SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0 Xml; HDR=YES; Database={filename};', ['MySheet$']);.
Problem, that I have few tables on the same sheet with ...
1
vote
1
answer
2k
views
OPENROWSET with Excel file returns DBSCHEMA_TABLES_INFO error
I’m using SQL Server 2017 Developer Edition (RTM-CU30) and Office Professional Plus 2016, both 64-bit, on Windows 10 Pro.
I created a simple Excel workbook with the following entries and saved it to C:...
0
votes
0
answers
113
views
SQL Server Bulk Insert from UNC location returning no records and no errors
I have a CSV file on a network drive that I want to load using bulk insert in a stored procedure in SQL Server. This CSV file has record delimiters like "text1","text2" etc. The ...
-1
votes
1
answer
159
views
Unable to remove red underlines for XML import object in SQL Server Select
I am importing an XML file into SQL Server 2019 using SSMS from a Windows 10 desktop. The script works but there are red underlines showing in the editor that make the code look like something is ...
0
votes
0
answers
397
views
Openrowset password protected excel file
I am getting the below error message and am trying to find the correct syntax to specify the user id/password to connect to the excel file. Can you help with how this should be input?
OLE DB provider ...
0
votes
0
answers
174
views
Incorrect syntax near the keyword 'EXEC'- OPENRPWSET
I am trying to load data into SQL server table. here is my code;
from OPENROWSET('SQLOLEDB', 'Server=(local);Trusted_Connection=yes;',
'EXEC [dbo].[sp_model1] @model = ''predict1''',
...
0
votes
1
answer
590
views
Can't access Excel file from Python and get error No such file or directory?
I work with SQL Server 2019 and Python 3.10.
When I try to read an Excel file with OPENROWSET using this statement:
SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0 Xml;Database=\\192....