Copy database fails with SQL Agent not started error, but it is running - sql-server-2012

I'm trying to copy a database to another server. I've successfully done this with these two servers several times, the last time was just a few days ago. However, now when I try to execute it, I get an error:
TITLE: Copy Database Wizard
------------------------------
Start failed for Job 'CDW_xxxx_SGSTG51DBA01_13_2'.
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch
(Microsoft.SqlServer.ConnectionInfo)
------------------------------
SQLServerAgent is not currently running so it cannot be notified of this action.
(Microsoft SQL Server, Error: 22022)
Base on this information, I immediately checked that SQL Agent was running. It wasn't, so I started it. I ran it again, but got the same error. I then double checked that the login information provided for both the source and destination servers was correct. It was.
So I'm now getting this error with verified connection information and SQL agent is running. What else could be causing this problem? Does the account running SQL agent need access to both servers?

Related

SQL Server Integration Services 2016 error, cannot bulk load XML file

My SSIS package fails on "Execute SQL Talk" which executes a stored procedure trying to load XML file. I get the following error:
[Execute SQL Task] Error: Executing the query "exec [dbo].[AccuplacerXMLProcessing] ?" failed with the following error: "Cannot bulk load. The file "J:\Accuplacer\000753-001\16209412.xml" does not exist.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
However, when I execute the same stored procedure in SSMS when connected as the same user it succeeds.
Both SQL Server Agent job and execution via SSMS were done by the same Windows domain user. This user has bulkadmin role on the server.
File is located on the server where the job is running.
There should not be any issues accessing the file. I've spent all day staring at this and cannot figure it out.
J:\Accuplacer\000753-001\16209412.xml" does not exist
Either the file is not there or the user does not have access to it on some level.
I noticed that the file name in your error is different than in your screen shot.

Job fails when loading data from server1 to server 2 inside SQL Server agent

I have created a ssis package to load data from server 1 table1 to server 2 table2. This package is running fine inside the business intelligence studio. But the issue is , when I schedule this package in SQL server agent as a job, the package execution is failing.
The error I am getting is
SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E4D. Description: "Login failed for user 'Domain\Server1$' .
Description: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.
The AcquireConnection method call to the connection manager "Server2.Database2" failed with error code 0xC0202009.
Please help me to fix the issue. I am using SQL Server 2014
Thank you very much for your time and help!
This is a security / permissions issue. Update the SQL Server Agent job to use an account which has sufficient permissions to complete all of the actions inside the SSIS package.
Explanation
The package completes succesfully when executed from Business Intelligence Studio, because that execution is running under you credentials. It is running as you. When you run the package from SQL Service Agent job, it is NOT using your credentials. Instead it is using account 'Domain\Server1$' and that account does NOT have sufficient rights against Server2.Database2 to complete all of the package actions.
To solve this, you could update the security on Server2.Database2 and allow 'Domain\Server1$' to perform the same actions as you, but that is unadvised. Instead, best practice here is to establish an SSIS proxy account. Here is a good article discussing how to go about that. After you have established this proxy account, grant the new proxy account sufficient permissions to complete the actions inside of your SSIS package and your error message will go away. Hope this helps!

Issue with SSIS package executing procedure that reads from a file share

I have an SSIS Package that runs via a SQL job on a SSIS server (Server A) that executes a stored procedure on the database server (server B). This stored procedure does a Bulk insert from a file share that is located on the SSIS Server (Server A). However, every time that the stored procedure runs it fails with the follow error:
Execute Membership Process:Error: Executing the query "exec storedprocname ?, ?" failed with the following error: "Cannot bulk load because the file "\ServerA\TestLoads\Membership\Processing\filename.csv" could not be opened. Operating system error code 5(Access is denied.).". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
I am pretty positive that the issue is related to permissions. If I store the files on the database server (Server B) then it processes. Or if I run the proc manually, it will work.
When I execute the job on Server A it executes as the service account for that server. That account has full access to Server A and Server B (Admin in SQL and on the server). I believe what is happening is the credentials get passed the first time, but they are not continued once the stored proc runs. I ran wireshark on Server A (SSIS Server) so that I could see what was access the share and try to get some more information. What I found was that there was no account information being passed, it was just blank.
I went through a lot of steps just to try to see if could get that work such as granting everyone access to the share, enabling the guest account, allowing anonymous users, etc. Not stuff I would want to do, but trying to narrow down the issue. None of those worked.
I tried modify the stored proc to use WITH EXECUTE AS OWNER. Still did not work, but got a different error. Also tried a variety of other accounts to execute as and got the same error each time.
Execute Membership Process:Error: Executing the query "exec [storedprocname] ?, ?" failed with the following error: "Could not obtain information about Windows NT group/user '', error code 0x5.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Tried a variety of solutions that I found online to get this to work and nothing so far has done it.
I understand that is not an ideal solution. I was under the impression that the developers where using SSIS to load the file initially and then using SQL for the rest of the process which would have worked. But because SQL has to touch the file system it keeps failing. And at this stage, there is not the option of rewriting this. Additionally, this process will work if we move the files to the database server (Server B), but that eliminates a large need for us in having the SSIS server in the first place which was to get files being processed off of the database server
Any ideas on if there is a way to get the current solution to work? Basically, what I think I am needing is to run the SSIS package and for a way to pass credentials via the stored proc to the file share during that process.
We are using Windows Server 2012 R2 on both servers and SQL Server 2012 sp3 Developer edition.
Thanks for the help!
I've had this issue before, and I still don't fully understand Kerberos authentication, but that fixed it for me. It's something to do with "double-hop" of authentication i.e. creds going from SSIS, through SQL Server, to a network Server.
Try setting up Kerberos Authentication for SQL Server. There are detailed step-by-step instructions with screenshots here => Setup Kerberos Authentication for SQL Server
I understand this is like a "link-only" answer, but I don't want to copy-paste & plagiarize the author's original works i.e. blog post, hence the link.

DTSX package runs in Visual Studio but not when called from a Database Job

I have an SSIS package that takes database backups and it runs fine in visual studio but when executed from a database job it fails with the following error. The part I can't understand is that 'GS\BOS-DBMONITOR$' isn't a user. 'BOS-DBMONITOR' is the server name.
Error:
Executed as user: NT Service\SQLSERVERAGENT. Microsoft (R) SQL Server Execute Package Utility Version 11.0.2100.60 for 64-bit Copyright (C) Microsoft Corporation. All rights reserved. Started: 10:58:03 AM Error: 2014-07-30 10:58:04.33 Code: 0xC0024104 Source: Back Up Database Task Description: The Execute method on the task returned error code 0x80131904 (Login failed for user 'GS\BOS-DBMONITOR$'.). The Execute method must succeed, and indicate the result using an "out" parameter. End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 10:58:03 AM Finished: 10:58:04 AM Elapsed: 0.593 seconds. The package execution failed. The step failed.
SQL Server Agent is the scheduler that comes with SQL Server. The first line of your error, Executed as user: NT Service\SQLSERVERAGENT specifies that your instance is running as the system user - not a "real" account. This machine is then trying to reach out to another computer and asks to log in to that SQL Server instance. SQL Server says "I'm not allowed to talk to strangers and GS\BOS-DBMONITOR$', you're strange."
How do you resolve it?
You need to let the foreign machines know about the account that's going to talk to them.
Use SQL Server Configuration Manager to change the service account from the the local account to a domain account MyDomain\NonExpiringAccount
Create a Credentialed user in the SQL Server instance on BOS-DBMONITOR and then assign them as a proxy for executing this, and any similar, SSIS packages. This allows the credentialed users' account to be presented to the foreign hosts. This has less potential impact on existing operations than changing the service account but requires more work
There's probably some voodoo you can work on all the servers you need to take a backup on to allow this user to log on but I wouldn't even go down that road. It's going to be work you have to perform on a per box basis and there's probably some security implications that go over my head

Unable to execute query against a linked server inside a SQL Job

My server setup is a bit weird. One of my DB Admins added a Linked Server to my server. In the linked server properties, I see the following in the Security view:
Local server login to remote server login mappings:
Local Login Impersonate Remote User Remote Password
domain\myusername CHECKED
For a login not defined in the list above, connections will:
- Be made using the security context
Remote login: linkedserveruser
With password: **************
Therefore, when I created a stored procedure with the following:
SELECT *
INTO #TEMP
FROM LINKEDSERVERNAME.DBName.dbo.TableName
-- Update local table after processing #TEMP
And setup a SQL job, it was failing with the following message:
Message
Executed as user: NT AUTHORITY\NETWORK SERVICE. Login failed for user 'linkedserveruser'. [SQLSTATE 28000] (Error 18456). The step failed.
After, digging through documentation, I found a KB811031 article that explains this problem and suggested that I map the security context and run the job as osql.
I did not have to map the security context because (as you can see from the settings of the linked server above), it already was mapped. I changed the Type to Operating System Command as suggested. When I run the job now, I get the following message:
Executed as user: domain\MYMACHINENAME$. Msg 18456, Level 14, State 1, Server SOMEOTHERDATABASENAME, Line 1 Login failed for user 'linkedserveruser'. Process Exit Code 0. The step succeeded.
And the job quits reporting success when in fact it failed. Any suggestions on how I can get this type of stored procedure containing a query to a linked server to run as a SQL job?