SSIS: Enabling transactions causes database connection to fail - sql-server

I have a package that I'm using to load records from a CSV file into a table. It has three elements in the control flow:
Truncate table
Load File into Table
Verify that there are records on the table after the load or raise an error
The idea is to have a single transaction on the package, so if the load of elements fails or the file was empty then the transaction is rolled back and the table isn't truncated.
To enable the transaction I just go to the package properties and set TransactionOption=Required, then I just try to execute the package and get this error while trying to execute the first element (The SQL task that tries to truncate the table):
[Execute SQL Task] Error: Failed to acquire connection "Database
Connection". Connection may not be configured correctly or you may not
have the right permissions on this connection.
If I just go back and change the TransactionOption property of the package to the default (Supported) then the package executes correctly but if there's an error there's no rollback.
I am using ADO.NET to connect to a SQL Server DB.
Any idea of what am I doing wrong? Is this the correct way to use transactions or am I missing something?
Thanks!

I know this is an old topic, but I had the same problem as you - the package works fine until I set one of the containers transaction's option to TransactionOption=Required
From what I understand, this might be related to Microsoft Distributed Transaction Coordinator (MSDTC) service not being started on the SQL server.
When I had this issue I checked if MSDTC is started on the machine on which I was running the package - it was. Sadly, I couldn't access the SQL server to check the same thing.
But, following these steps on the machine running the package solved the problem:
On Windows Server 2008 and Windows Vista:
Click Start, click Run, and type dcomcnfg to launch the Component Services Management console.
Click to expand Component Services and click to expand Computers.
Click to expand My Computer, click to expand Distributed Transaction Coordinator, right-click Local DTC, and click Properties.
Click the Security tab of the Local DTC Properties dialog.
In that dialog box, I had to enable "Network DTC Access" and also "Allow Inbound" and "Allow Outbound".
Sources:
msdn forum about this
msdn article about troubleshooting Problems with MSDTC

Related

Error 0xC0011008 the package failed to load

I'm facing a strange behavior of SQL Server Agent when executing SSIS packages.
I have a job that includes many steps (mainly SSIS packages). Some steps fail mostly every day even the configuration is the same for all the steps.
I tried to delete/create the job, delete/create the SQL Server Agent Proxy but with no sucess.
I can't find any difference between the steps that fail and the ones that succeed.
This is the error returned by SQL Server Agent :
The package failed to load due to error 0xC0011008 "Error loading from XML. No further detailed error information can be specified for this problem because no Events object was passed where detailed error information
SQL Server version : 2014
SSIS version : 2014
EDIT :
In the Event Log I found an Information Message from User Profile Service that says :
Windows detected your registry file is still in use by other applications or services. The file will be unloaded now. The applications or services that hold your registry file may not function properly afterwards
Process 5924 (\Device\HarddiskVolume2\Program Files\Microsoft SQL Server\120\DTS\Binn\DTExec.exe) has opened key \REGISTRY\USER\S-X-X-XX-XXXXXXXXXX-XXXXXXXXXX-XXXXXXXXXX-XXXX\Control Panel\International
Process 5924 (\Device\HarddiskVolume2\Program Files\Microsoft SQL Server\120\DTS\Binn\DTExec.exe) has opened key \REGISTRY\USER\S-X-X-XX-XXXXXXXXXX-XXXXXXXXXX-XXXXXXXXXX-XXXX\Software\Microsoft\Windows\CurrentVersion
The SID corresponds to the Proxy User used to execute the SQL Job steps. And the timestamp corresponds is the same when the error occures in SQL Agent.
I think this is what causes the steps to fail.
Could we prevent Windows unloading this registry ?
The error was indeed caused by the fact that the User Profile Service forces the unloading of the Registry.
The solution that worked for me was to change the policy setting Do not forcefully unload the user registry at user logoff from "Not Configured" to Enabled.
Start the Local Group Policy Editor (gpedit.msc)
Go to Computer Configuration > Administrative Templates > System > User Profiles
Set "Do not forcefully unload the user registry at user logoff" to Enabled
Run gpupdate command.
Details can be found here : https://support.microsoft.com/en-us/help/2287297/a-com-application-may-stop-working-on-windows-server-2008-when-a-user

The report server was unable to validate the integrity of encrypted data

The report server was unable to validate the integrity of encrypted data in the database. (rsCannotValidateEncryptedData) .
Could not restore the encryption key, so I deleted the keys and tried to regenerate with rskeymngt with no luck. Getting
'The report server was unable to validate the integrity of encrypted
data in the database. (rsCannotValidateEncryptedData)'
I get that error when accessing http://localhost/ReportServer and when running rskeymgmt -s.
Not sure what next step to take. I have reports that users need to access.
I went into SSRS Configuration Manager > Encryption Keys > click Delete.
When I did that I got the error:
Failed to delete the encryption content in the report server database. Please execute the "DeleteEncryptedContent" stored procedure on the database manually.
To fix it I opened SQL Server Mgmt Studio > expand Databases > right click Report Server > new query and execute:
exec DeleteEncryptedContent
Start > Run > services.msc > Restart the "SQL Server Reporting Service" and its working.
Restarted the services and now everything is working.
So it looks like in order to generate a new key I need to update the Report Server Service account. After that restart the sql server reporting services.
I no longer have the encryption error, but now I am asked for a log in to the data source after clicking on the report. I enter the creds again but get 'The ConnectionString property has not been initialized.'
Just go to the reporting service manager and delete the delete encrypted content or change content now try to connect once more it will be work.
You just need to change database again if you already created then your problem will be solved.
One reason for this could be that the encryption key did not restore correctly. I migrated a report database from one server to another. I restored the encryption key and all seemed well at first but the error the questioner posted started appearing shortly thereafter. Another site had posted a query to look at the keys in the report database (with further instructions of how to delete) and I noticed when I executed it that the SymmetricKey field for my server was NULL. I restored the encryption key again using the Report Server Configuration Manager and noticed that the SymmetricKeys was now populated. I was then able to browse to the report server.

My SSIS Package works, but fails as a SSMS job (Error: 0xC0016016)

My SSIS Package works, but fails as a SSMS job (Error: 0xC0016016)
I am posting this question and sharing my solution to this issue as my own question because I didn't see the posed problem match the specific issue I encountered and the answers seemed to be scattered in different forum questions.
Background:
I have four SSIS packages on SQL Server 2012 that import a table from SQL Server 2008 R2, 2008, or 2005, depending on the specific package. I use a designated sql server login and password for the source database and integrated Windows security for the target database.
Within SSIS I am able to run each package without a problem.
To ensure this package ran on a schedule, I set up a SSMS job on the same server as the SSIS package. In Job step properties, I chose: SQL Server Integration Services Package > run as SQL Sever Agent Service Account > Package source: File system).
The Symptom:
When manually running the job to make sure it worked, I got an error and saw this in the Log File Viewer. This was the first of several errors, but as this was chronologically the first error, I looked into this one first.
Error: 2014-10-24 09:52:34.48
Code: 0xC0016016
Source: [Redacted -- the correct name of the table I was importing]
Description: Failed to decrypt protected XML node "DTS:Password" with
error 0x8009000B "Key not valid for use in specified state.". You may
not be authorized to access this information. This error occurs when
there is a cryptographic error. Verify that the correct key is
available.
End Error
I looked up the error code on Google and started looking at resolutions. Rather than retelling how I found the bits and pieces of the resolution, I am presenting an actionable result in sequence -- at least for me and the network infrastructure I'm working with.
In the "properties" panel of the SSIS solution (do this first) and each package in that solution, reset the "ProtectionLevel" attribute to EncryptSensitiveWithPassword and set a password. The package passwords must match the solution password.
Just a double-check, run your packages in debug mode to make sure that no other new issues arise. In my case, I needed to re-enter the sql server password for the source server database.
Rebuild your SSIS solution.
In SSMS, open your job and open the job step properties for the task in question.
Select the "Command Line" tab. A "Package Password" popup appears. Enter the password that you entered in step 1.
Select "Edit the command line manually" and place the same password from step 1 immediately after /DECRYPT.
Repeat steps 4-6 for each job step that runs this type of package.
Press the "OK" button and re-run your job.
I was able to run my job successfully after that.

Stop SQL Server jobs from adding event log for success

My eventlog is cluttered with Package "<name>" finished successfully messages; is there any way to stop these from being added to the log?
The packages in question run very frequently and are making the eventlog harder to use
This is running from SQL Server 2008 R2 (Standard)
The job properties are set with Write to the Windows Application event log - When the job fails (and sends an email to an operator and in the corresponding maintenance plan, the settings for "Reporting and Logging" are all set with nothing checked.
And the SQL Server Agent properties are set only with the fail-safe operator; by email
For the life of me, I cannot see anywhere in SQL where I can suppress the "success" messages and would appreciate help.
I have just encountered a very similar scenario.
I have a couple of packages that are scheduled frequently. Monitoring of these non-critical packages can be managed within SQL Server Management Studio itself, I have no need to log events to the Windows Application logs.
In fact the logs are now "bloating" insofar as they are filling at a far greater pace than I am happy with.
It is possible to switch package logging on or off within the SSIS package itself.
From within BIDS (Business Intelligence Design Studio), right click anywhere within the control flow and select "Logging..." from the menu that appears.
From what I have read of this, to set your own custom logging options you have to tick the option on in the "Providers and Logs" screen and then add the "SSIS log provider for Windows Event Log" provider.
Once you have done that, you can tick options on and off within the "Details" tab. The options are all unchecked by default.
In the alternative, you could set up logging to the "SSIS log provider for SQL Server" and select the items that you do want to monitor. This then logs activity to a table called dbo.sysssislog in whichever database you configure within the provider.
You can get details on SSIS package logging here: http://msdn.microsoft.com/en-gb/library/ms181205(v=sql.100).aspx

What state is my SQL server database in when msdeploy fails on user creation?

I am using msdeploy (version 2) to transfer a database from machine A to machine B.
On in the database on machine A there are some users that do not exist on machine B, thus the transfer (partially) fails with the message:
Error Code: ERROR_SQL_EXECUTION_FAILURE
More Information: An error occurred during execution of the database script.
The error occurred between the following lines of the script: "3" and "5".
The verbose log might have more information about the error.
The command started with the following: "CREATE USER [someDomain\someUser] FOR LOGIN [someDomain"
Windows NT user or group 'someDomain\someUser' not found.
Check the name again. http://go.microsoft.com/fwlink/?LinkId=178587
The database seems to be transfered, except for the user creation. Does anyone know what state the database is in after this failure?
Is there any way I can transfer the database without the users (or better without specific users) using msdeploy?
Web Deploy uses SMO (SQL Management Objects) to script out and apply the scripts for SQL databases, and exposes most of the SMO settings with the dbfullsql provider (so, most of these options: http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.transfer_properties.aspx). If you want to skip the users due to this kind of login-not-exists or user-not-found error, you should be able to do this by adding the scripting option: copyAllUsers=false to the source of the sync. For example:
msdeploy.exe -verb:sync -source:dbfullsql="Data Source=.\SQLExpress;Initial Catalog=MySourceDb;User Id=localUser;Password=LocalPass",copyAllUsers=false -dest:dbfullsql="Data Source=RemoteSQLServer;Initial Catalog=MyDestDb;User Id=remoteUser;Password=RemotePass"
Incidentally, I am surprised you note the db appears to have been sync'd - I would expect this is not actually the case. If you have the permissions for it, Web Deploy will create the database if it did not already exist when it initially tries to make the connection, but your failure occurred very early in the script execution, and I believe Web Deploy dbfullsql syncs are transacted by default (the db creation is separate from the script execution and is not transacted). Thus the db may exist where it did not pre-sync, but I wouldn't expect the data to be present in it.

Resources