Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

" The job failed" in copying database SQL Server 2012

Tags:

I'm trying to copy a database. When going through the Copy Database Wizard, I'm getting a Execute SQL Server Agent Job error. The error states

The job failed. Check the event log on the destination server for details

Performing operation

  • Add log for package (Success)

  • Add task for transferring database objects (Success)

  • Create package (Success)

  • Start SQL Server Agent Job (Success)

  • Execute SQL Server Agent Job (Error)

Error:

The job failed. Check the event log on the destination server for details. (Copy Database Wizard)

I can't seem to find what causing this problem. Am I using the correct approach? I just need to copy this database. Thanks in advance.

like image 326
mohammad_hasan Avatar asked Jan 18 '15 07:01

mohammad_hasan


People also ask

How do I copy a database from one SQL server to another?

On either the source or destination SQL Server instance, launch the Copy Database Wizard in SQL Server Management Studio from Object Explorer and expand Databases. Then right-click a database, point to Tasks, and then select Copy Database.

What is copy database in SQL server?

The Copy Database wizard does not delete a source database if you select the Copy option. You cannot copy a database from the source SQL Server instance to the target if the exact same database is hosted on the target SQL Server instance. In this case, you must select the Override option.


2 Answers

if you are trying to Clone your database on the same server try this:

  1. Create a backup of the database you want to copy
  2. right-click on Databases and select Restore Database
  3. Select the database you want to copy from the From Database drop-down list in the Source for restore section
  4. Enter the name of the new database in the To database field in the Destination for Restore section - this cannot be the name of an existing database.
  5. Click OK
like image 117
safi Avatar answered Sep 19 '22 15:09

safi


Check the Windows Event Log.

  1. Event Viewer
  2. Windows Logs
  3. Application
  4. Look for Warning/Error messages associated with any of the following:
    • SQLAgent
    • SQLISPackage
  5. Read the error.

Here is an example.

SQLAgent Related Errror

Here are some of the errors and resolutions we encountered.

Unable to determine if the owner (...) of job ... has server access (reason: Could not obtain information about Windows NT group/user '...', error code 0x54b. [SQLSTATE 42000] (Error 15404)).

We needed to make sure that during the Copy Database Wizard, the account with which we signed in to the destination server had the appropriate privileges and that those privilege were obtainable (we eventually used the sa account.) That resolved the above warning.

Access is denied

We needed to make sure that the local SQL Server Agent has appropriate privileges on the local server. So, we made the SQL Server Agent logon as Local System. That worked because Local System is a sysadmin in our SQL Server instance.

Could not read metadata, possibly due to insufficient access rights.

We needed to give the Local System account further privileges.

  • From SSMS
  • Right click on the server name and click properties
  • Click on the Permissions tab
  • Click the user Local System
  • On the Explicit Permissions almost at the bottom there is "View Any Definition" grant that. See if that will work.

xp_regread() returned error 5, 'Access is denied.'

This stymied us and we asked another question: xp_regread() returned error 5, 'Access is denied.'

like image 37
Shaun Luttin Avatar answered Sep 17 '22 15:09

Shaun Luttin