Fix it now
Agent is refusing the edit because the job records an originating server that is not this one. Its published text is that you cannot add, update or delete a job, its steps or its schedules when the job originated from an MSX server. After a machine rename, every job created before the rename looks foreign, and the fix is to correct the name SQL Server holds.
SELECT @@SERVERNAME AS sql_name, SERVERPROPERTY('MachineName') AS windows_name;
EXEC sp_helpserver;
EXEC sp_dropserver 'OLDNAME';
EXEC sp_addserver 'NEWNAME', local;
- Compare the two values from the first query. If they differ, SQL Server is still using the old machine name.
- Take the exact string from
sp_helpserverfor the local server before you drop it; error 15015 is published as the server not existing and pointing you atsp_helpserver, and it is what you get from a near miss. - Run the drop and add. For a named instance use
HOST\INSTANCEin both statements. - Restart the SQL Server service and then SQL Server Agent. The value behind
@@SERVERNAMEis read at startup and will not refresh on its own. - If the job genuinely came from a master server, do not edit it locally; make the change on the master, or defect this instance from it.
Do not rename an instance that is configured for replication or mirroring. Microsoft documents renaming as unsupported for computers involved in replication, and mirroring has to be turned off first and re-established afterwards.
If the job saves after the restart, you are done. If the name was already correct, the next section covers the other two ways a job can look foreign.
Why it happens
Multi-server administration lets one master server push jobs to targets. So that a target cannot silently diverge from its master, Agent records where each job came from and refuses local changes to jobs that originated elsewhere. That check runs on every job on every instance, whether or not you have ever used multi-server administration, which is why a feature most people never configure produces an error most people eventually meet.
Renaming Windows does not update the name SQL Server holds. The old value stays in the server list until you replace it, so @@SERVERNAME keeps reporting a machine that no longer exists and jobs created under the old name now look as though they came from somewhere else. Microsoft’s documented correction is exactly the two statements above, followed by a restart of the instance.
The companion codes are ordinary parameter complaints and are worth reading literally. Error 15015 is published as the server not existing, with the advice to use sp_helpserver to show the available servers, which is what you get when the string you typed is not the one recorded. Error 14261 is published as the specified object already existing. Error 14234 is published as the specified value being invalid, with the note that valid values are returned by a named procedure, which tells you where to look rather than guessing.
There is a third possibility that has nothing to do with renaming: the job really did come from a master server, because this instance is enlisted as a target. In that case the refusal is the feature working, and the fix is to make the change where the job lives or to defect the target from the master.
The machine was renamed and SQL Server was never told
You have this one if @@SERVERNAME returns the old name, and every job created before the rename refuses to be edited.
- Run
sp_dropserverfor the old name andsp_addserverwith the new name and thelocalargument. - Restart SQL Server and then Agent, and confirm
@@SERVERNAMEnow matchesSERVERPROPERTY('MachineName'). - Check everything else that stored the old name: linked servers, remote logins, monitoring configuration, connection strings.
Renaming is not supported for a failover cluster instance; that has its own documented procedure through the cluster tools.
msdb was restored onto a different instance
You have this one if The server name is right, the jobs are not, and they arrived with a restore of msdb from another server.
- Script the affected jobs out from Management Studio, including schedules, steps and notifications.
- Delete the imported jobs and run the script to recreate them under this instance’s name.
- Review job owners and proxies in the script first, since those accounts may not exist here.
The instance really is a target of a master server
You have this one if The instance shows as enlisted in multi-server administration and the jobs came down from the master.
- Make the change on the master server so it flows down to the targets, which is how the feature is meant to work.
- To make the instance stand alone, run
EXEC msdb.dbo.sp_msx_defect;on the target, which requires sysadmin. - If the master is gone, use
EXEC msdb.dbo.sp_msx_defect @forced_defection = 1;and then have a sysadmin on the master runsp_delete_targetserverto complete the defection.
The correction itself is being rejected
You have this one if Error 15015 from the drop, 14261 when recreating something, or 14234 on a parameter that looks right.
- Run
EXEC sp_helpserver;and use the exact string it returns, including the instance name. - For 14261, delete or rename the existing object before recreating it.
- For 14234, use the procedure the message names to list the valid values rather than guessing at the right one.
Full reference
Which situation you are in
| What you find | What to do |
|---|---|
@@SERVERNAME does not match SERVERPROPERTY('MachineName') |
Replace the entry with sp_dropserver and sp_addserver, then restart |
| The name is correct but old jobs still refuse edits | The jobs carry another originating server; script and recreate them |
| The instance is enlisted with a master server | Change the job on the master, or defect the target |
sp_dropserver returns 15015 |
The name you typed is not the one recorded; read sp_helpserver |
Defecting a target properly
- On the target, run
EXEC msdb.dbo.sp_msx_defect;. It requires membership of the sysadmin fixed server role. - If the master’s msdb is gone or irreparably damaged, use
@forced_defection = 1instead. - After a forced defection, a sysadmin on the master must run
EXECUTE msdb.dbo.sp_delete_targetserver @server_name = 'target', @post_defection = 0;to complete it. - Confirm the target’s jobs are now editable locally, and review their owners.
- Note that this procedure edits the Windows registry, which is a reason to run it rather than to reproduce it by hand.
What a rename touches beyond the server list
- Linked servers and remote logins that name the old host.
- Job steps, packages and connection strings with the old name embedded.
- Monitoring, backup software and any agent that registered the instance by name.
- Kerberos service principal names registered against the old host name.
- Anything that stored the old name inside a database, which nothing in the rename procedure will find for you.
Where renaming is not supported at all
| Configuration | Position |
|---|---|
| Failover cluster instance | Not supported by this procedure; use the documented cluster route |
| Replication | Renaming a computer involved in replication is not supported |
| Database mirroring | Turn mirroring off before the rename and re-establish it afterwards |
| Reporting Services | May not be available after a computer name change |
Editing the job tables in msdb directly is a widely circulated shortcut and it is not supported. If you take that route anyway, back up msdb first, do it with Agent stopped, and expect no help if the instance behaves oddly afterwards.
Checking the change actually took
The two statements are quiet: they return nothing useful and they do not take effect until the instance restarts, so it is easy to believe you have fixed something you have not. Run the comparison query again after the restart, and read it rather than assuming.
| Check | What you should see |
|---|---|
SELECT @@SERVERNAME; |
The current machine name, or HOST\INSTANCE for a named instance |
SERVERPROPERTY('MachineName') |
The same host name |
EXEC sp_helpserver; |
One row for the local server, carrying the new name |
| Editing a previously blocked job | It saves |
| The Agent error log after a restart | No entries about an unknown or mismatched server name |
If @@SERVERNAME still returns the old value after a restart, the drop and add did not both succeed. Read sp_helpserver again: a 15015 on the drop leaves the old entry in place, and adding the new name without dropping the old one leaves two entries and no improvement.
Every code this article covers
| Code | What it points at | Source |
|---|---|---|
14274 |
Cannot add, update or delete a job, or its steps or schedules, that originated from an MSX server | Microsoft Learn |
14261 |
The specified object already exists under that name | Microsoft Learn |
14234 |
The specified value is invalid; the message names the procedure that returns the valid values | Microsoft Learn |
15015 |
The server does not exist; use sp_helpserver to show the available servers | Microsoft Learn |
Confirm the fix worked
SELECT @@SERVERNAME, SERVERPROPERTY('MachineName');returns two values that match.- A previously blocked job saves after an edit.
- Agent restarts cleanly with nothing in its log about the old name.
- One scheduled job runs on its own and completes.
- Linked servers and remote logins that named the old host have been checked.
Questions people ask about this
Do I have to restart after sp_addserver?
Yes. The value behind @@SERVERNAME is read when the service starts, so until you restart SQL Server and then Agent, the instance keeps using the old name and the jobs keep refusing edits.
Does this cost anything?
No. It is a metadata correction. No licence, edition or key is involved in what an instance calls itself.
Can I rename a clustered instance or a replication publisher this way?
No. A failover cluster instance has its own documented procedure, and renaming a computer involved in replication is not supported. Mirroring has to be turned off before the rename and set up again afterwards.
Will the jobs run correctly once the name is fixed?
They will be editable again, which is the immediate problem. Check their owners and any credentials or proxies as well, since an account that resolved on the old server may not resolve here.
The name is already right and one job still will not save. What now?
That job carries a different originating server, which usually means msdb was restored from another instance or the server is genuinely enlisted with a master. Script the job out and recreate it locally, or defect from the master.
