When upgrading your SQL Server, it can sometimes be easier to rename the new server to match the old server rather than update all the workstations to point to the new server. The name of the SQL Server instance also needs to be changed. The following script will take care of this, but the last part which updates the SQL Agent jobs only works against the master server in a multi-server environment. If you're upgrading your master server, or your only server, it will work fine.
- DECLARE @var1 nvarchar(50)
- DECLARE @var2 nvarchar(50)
- SET @var1 = convert(nvarchar(50),@@SERVERNAME)
- SET @var2 = convert(nvarchar(50),SERVERPROPERTY('MachineName'))
- EXEC sp_dropserver @var1
- EXEC sp_addserver @var2, 'local'
- UPDATE msdb.dbo.sysjobs SET originating_server = @var2
You need to login to post a comment.