Azure SSIS IR - working with files in the temp folder of the IR node - azure

I have setup a custom SSIS IR, however I'm having problems reading files from the current working directory or temp folder on the IR node
https://learn.microsoft.com/en-us/sql/integration-services/lift-shift/ssis-azure-files-file-shares?view=sql-server-2017
The work flow of my test package is
Load compressed file to Azure file share
Unzip file
Modify file, saving it the current working group folder on the IR node (this path .\testfile.json)
Load file to Azure SQL DB
The last step is where I'm having issues, I receive the below error message. Maybe looks to be related to security, but no idea how to access the SSIS IR node to check this.
Execute SQL Task:Error: Executing the query "DECLARE #request
VARCHAR(MAX) SELECT #request =..." failed with the following error:
"Cannot bulk load because the file ".\testfile.json" could not be
opened. Operating system error code (null).". Possible failure
reasons: Problems with the query, "ResultSet" property not set
correctly, parameters not set correctly, or connection not established
correctly.
How can I fix this issue?

From just the error message, looks like you're using BULK INSERT in Execute SQL Task to load data into Azure SQL DB. BULK INSERT into Azure SQL DB can only work from Azure Storage Blob, but not from file systems/SSIS IR nodes. To load data from the current working directory of SSIS IR nodes into Azure SQL DB, you can use a Data Flow with Flat File Source and ADO.NET Destination.

Related

Can't access files via Local file API on Databricks

I'm trying to access small text file stored directly on dbfs using local file API.
I'm getting the following error.
No such file or directory
My code:
val filename = "/dbfs/test/test.txt"
for (line <- Source.fromFile(filename).getLines()) {
println(line)
}
At the same time I can access this file without any problems using dbutils or load it to RDD via spark context.
I've tried specifying the path starting with dbfs:/ or /dbfs/ or just with the test folder name, both in Scala and Python, getting the same error each time. I'm running the code from the notebook. Is it some problem with the cluster configuration?
Check if your cluster has Credentials Passthrough enabled. If so, local file Api is not available.
https://docs.azuredatabricks.net/data/databricks-file-system.html#local-file-apis

Execute SQL file which contains multiple stored procedures in Node.js?

How can I execute a SQL file which contains multiple stored procedures and a lot of SQL script in Node.js?
I have tried to execute the sql file using npm package execsql but it doesn't work. Here is the link which I have tried.
Able to install
Did DB configuration
Getting this error while executing sql statement or sql file:
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'usernane'#'myipaddress' (using password: YES) –
Yet I am able to execute sql statements using npm package mysql with the same db configuration.

Distributed Queries in SQL Server, data from XLS

I would like to create a view in SQL Server 2008 that displays the data contained in an Excel file.
I do not want to use the import data as these data are updated.
I found this: http://support.microsoft.com/kb/321686/en
I made these commands to enable some options :
sp_configure 'show advanced options', 1
RECONFIGURE
GO
sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO
But when I try to read the Excel file with this query:
SELECT * FROM INTO XLImport3 OPENDATASOURCE ('Microsoft.Jet.OLEDB.4.0', 'Data Source=C:\Documents and Settings\jconnor\Desktop\Test.xlsx') ... [Sheet1$]
I back (it's a translation from french) :
The OLE DB provider " Microsoft.Jet.OLEDB.4.0 " for linked server " (null) " returned >message " Unspecified error " .
Msg 7303 , Level 16 , State 1, Line 1
Unable to initialize the object data source OLE DB provider " Microsoft.Jet.OLEDB.4.0 " for >linked server " (null) " .
Does someone have any clue ?
Thank you in advance
Kal,
So your main error is likely this;
OLE DB provider "MICROSOFT.JET.OLEDB.4.0" for linked server "(null)" returned message "Unspecified error".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MICROSOFT.JET.OLEDB.4.0" for linked server "(null)".
I would check some permissions.
Check the permissions on the Temp folder
This is needed because the provider uses the temp folder while retrieving the data. The folder can be one of the below based on whether you use a local system account or network domain account.
For network accounts, folder is
\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp
and for local system account its \Windows\ServiceProfiles\LocalService\AppData\Local\Temp
Right click on this folder and give it read write access to the account (or group) executing the code. That solved the error for me.
Also
http://blogs.msdn.com/b/spike/archive/2008/07/23/ole-db-provider-microsoft-jet-oledb-4-0-for-linked-server-null-returned-message-unspecified-error.aspx
This is because the SQL Server Service is trying to write the temp DSN to the temp folder for the login that started the service, in this case the Admin/Admin login.
The temp folder is something like: C:\Documents and Settings\Admin\Local Settings\Temp
.15 As mentioned, the OleDbProvider will always execute in the context of the user who initialized it, in this case User/User.
.16 User/User has no rights on this folder (C:\Documents and Settings\Admin\Local Settings\Temp).
If running FileMon when the SQL is executed, we can see the following:
(Actually, try using Process Monitor - http://technet.microsoft.com/en-us/sysinternals/bb896645)
sqlservr.exe:000 QUERY INFORMATION C:\DOCUME~1\Admini~1\LOCALS~1\Temp ACCESS DENIED Attributes: Error
So to summarize so far:
The SQL Server service is started as Admin/Admin, when the select is made, the OleDb provider is invoked by User/User.
Now the OleDb provider attempts to create a temporary DSN in the temp directory. This will be the temp directory for the SQL Server service (Admin/Admin)
but the user (in this case User/User) does not have write permissions on this folder. And the error occurs.
There are two ways to resolve this.
Option 1:
Log out of the machine and log in as the account that starts the SQL Server Service (in this case Admin/Admin) then start a command prompt
and type “set t” (no quotes), this will show something like:
TEMP=C:\DOCUME~1\Admin\LOCALS~1\Temp
TMP=C:\DOCUME~1\Admin\LOCALS~1\Temp
these are the environment variables set for %TEMP% and %TMP%, so go to that folder and right click and select Properties -> Security,
then add the user, in this case User/User, note that the default for the user is Read&Execute/List Folder Content/Read, this not enough, you have to select Write as well.
Log out, and log in again as User/User and rerun the command from SSMS. This time it should work.
Option 2:
Log on as Admin and change the TEMP and TMP variable to, for example, C:\Temp, basically this moves the Temp directory out of the Documents and Settings folder.
However, you must restart the SQL server for this to take effect.
So basically, what happens is that when SQL Server starts, it uses the Temp folder of the startup account (Admin/Admin) but the MICROSOFT.JET.OLEDB.4.0 will always execute
as the user who calls the SQL command (User/User) and this will fail unless this user does not have Write access to that temp folder.
Without knowing all setups out there, perhaps option 2 is the preferred solution since with option 1, you will have to add ALL the users that will invoke the provider which may not be practical.
Also, when changing the startup account for the SQL Server service, then the TEMP directory for that account will be used, and you will see the error again until you, again, give write permissions for all the users on this TEMP folder...or a user group (preferred).

Error when backing up a database in SQL Server 2008 R2

In XP machine, I am using SQL Server 2008 R2 to backup files, that the files are stored in the c:/ProgramFiles/.../Data folder, but in this case I got the exception
Cannot open backup device 'C:\Program Files\Data\BlaBla_123.bak'.
Operating system error 5 (failed to retrieve text for this error. Reason: 1815).
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.
My query
ALTER DATABASE BlaBla SET SINGLE_USER WITH ROLLBACK IMMEDIATE
backup database BlaBla to disk = 'C:\Program Files\Data\BlaBla_123.bak'
But I know this will work when I stored the backup file in the D drive or something,
My question is, How to save the backup in the Same folder and What I need to do from code side or query side?
I added Network Service (or of the accout that is assigned to the SQL Server service account) with Full Control permission to the ACL (Access Control List) of the backup .bak file.

Failed to generate scripts for Sql Azure database: "Getting the list of objects from : failed"

I follow http://msdn.microsoft.com/en-us/library/ee621790.aspx instructions and on get the following error:
Getting the list of objects from 'MYDBNAME'. Failed
Microsoft.SqlServer.Management.Sdk.Sfc.EnumeratorException: Failed to retrieve data for this request. ---> Microsoft.SqlServer.Management.Sdk.Sfc.InvalidVersionEnumeratorException: Operation not supported on version 11.0 SqlAzureDatabase. at Microsoft.SqlServer.Management.Smo.XmlReadDoc.LoadFile(Assembly a, String strFile) at Microsoft.SqlServer.Management.Smo.SqlObject.LoadInitData(String file, ServerVersion ver, DatabaseEngineType databaseEngineType) at Microsoft.SqlServer.Management.Sdk.Sfc.ObjectCache.LoadElement(ObjectLoadInfo oli, ServerVersion ver, DatabaseEngineType databaseEngineType) at Microsoft.SqlServer.Management.Sdk.Sfc.ObjectCache.GetElement(ObjectLoadInfo oli, ServerVersion ver, DatabaseEngineType databaseEngineType) at Microsoft.SqlServer.Management.Sdk.Sfc.ObjectCache.GetAllElements(Urn urn, ServerVersion ver, DatabaseEngineType databaseEngineType, Object ci) at Microsoft.SqlServer.Management.Sdk.Sfc.Environment.GetObjectsFromCache(Urn urn, Object ci) at Microsoft.SqlServer.Management.Sdk.Sfc.Environment.GetData(Request req, Object ci) at Microsoft.SqlServer.Management.Sdk.Sfc.Enumerator.GetData(Object connectionInfo, Request request) at Microsoft.SqlServer.Management.Sdk.Sfc.Enumerator.Process(Object connectionInfo, Request request) --- End of inner exception stack trace --- at Microsoft.SqlServer.Management.SqlScriptPublish.GeneratePublishPage.worker_DoWork(Object sender, DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
How to get azure database backup or sql scripts?
UPDATE:
Azure db: SQL Server 11.0.2065;
Sql management studio: 11.0.2100.60
UPDATE 2:
SQL Azure Migration Wizard reports:
Microsoft.SqlServer.Management.Sdk.Sfc
Failed to retrieve data for this request.
ADDITIONAL INFORMATION:
Operation not supported on version 11.0 SqlAzureDatabase. (Microsoft.SqlServer.SqlEnum)
The same here.
The collation is Cyrillic_General_CI_AS. How to change collation for the db to make scripts?
UPDATE 3:
The same error while making export of Data-Tier Application using this guide:
..Operation not supported on version 11.0 SqlAzureDatabase.
In SqlServer Management Studio 2012;
Right click on the DB and Tasks > Deploy Database to Sql Azure but select your local server as target. It will get copy of azure to your local. And then you can generate scripts from your local server. I just found this method, worked for me.
I would suggest to go for the SQL Azure Migration Wizard as it is far more advanced than the Generate Scripts task in SSMS. As a side note, this tool is written and maintained by a person from the SQL Azure team!
Ok, i did the exporting of my azure db using cloudservices.red-gate.com. I created BACPAC File on a storage. Then i imported the BACPAC to my local Sql express. Strangely enough the service didn't threw the error i had when used my SQL Management Studio.

Resources