Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Two days back our client changed one of our Dev Server name

After Server Renamed, All my maintenance jobs and other jobs are failing because server name mismatch.

We are using sql server 2012 version and server 2008 OS

So today morning i renamed my Sql server 2012 name to updated given name and made table, procedures updates

I tried to update Local server connection in maintenance job but it is uneditable. Then i added new server connection,still no use i am getting below error, while executing jobs.

After i tried with target page in jobs property option, there also only target server is selected and multiple target server is disable.

Error below

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: 12:01:28 AM Error: 2013-12-16 00:01:43.98 Code: 0xC00291EC Source: {410F7661-F71A-4B68-9584-BA422AB00F02} Execute SQL Task
Description: Failed to acquire connection "Local server connection". Connection may not be configured correctly or you may not have the right permissions on this connection. End Error
Error: 2013-12-16 00:02:00.00
Code: 0xC0024104
Source: Territory_Update
Description: The Execute method on the task returned error code 0x80131904 (A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)). The Execute method must succeed, and indicate the result using an "out" parameter. End Error
Error: 2013-12-16 00:02:15.00
Code: 0xC0024104
Source: {4E2AF328-0B8D-4905-83BE-839FDDEFC09C}
Description: The Execute method on the task returned error code 0x80131904 (A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)). The Execute method must succeed, and indicate the result using an "out" parameter.
End Error DTExec: The package execution returned DTSER_FAILURE (1).
Started: 12:01:28 AM
Finished: 12:02:15 AM
Elapsed: 46.641 seconds.
The package execution failed.
The step failed.

Help me out in this guys, Thanks in advance

share|improve this question
    
I got the same issue. Recreated maintenance plan. – Sarathi Reddy May 3 at 10:59

Maintenance plans make use of SSIS packages that are stored in MSDB. These packages use connection strings, which are not changed after a server rename.

Use the script (reproduced below) posted by NancySon in the comments of How to: Rename a Computer that Hosts a Stand-Alone Instance of SQL Server to get some inspiration on how to change these connection strings. Or recreate the maintenance plans.

Maintenance plans don't get their connections changed to the new server name and so they may break. After a rename you may find that you cannot delete or rename the existing maintenance plans, so either delete them before renaming the server and recreate them afterwards or run the following script to fix them:

   use msdb

   DECLARE @oldservername as varchar(max)
    SET @oldservername='<server name>\<instance name>'

   -- set the new server name to the current server name

   declare @newservername as varchar(max)
    set @newservername=@@servername

   declare @xml as varchar(max)
    declare @packagedata as varbinary(max)
    -- get all the plans that have the old server name in their connection string
    DECLARE PlansToFix Cursor
    FOR
    SELECT    id
    FROM         sysssispackages
    WHERE     (CAST(CAST(packagedata AS varbinary(MAX)) AS varchar(MAX)) LIKE '%server=''' + @oldservername + '%')

   OPEN PlansToFix


   declare @planid uniqueidentifier
    fetch next from PlansToFix into @planid

   while (@@fetch_status<>-1)  -- for each plan

   begin
    if (@@fetch_status<>-2)
    begin
    select @xml=cast(cast(packagedata as varbinary(max)) as varchar(max)) from sysssispackages where id= @planid  -- get the plan's xml converted to an xml string

   declare @planname varchar(max)
    select @planname=[name] from  sysssispackages where id= @planid  -- get the plan name
    print 'Changing ' + @planname + ' server from ' + @oldservername + ' to ' + @newservername  -- print out what change is happening

   set @xml=replace(@xml,'server=''' + @oldservername + '''','server=''' + @newservername +'''')  -- replace the old server name with the new server name in the connection string
    select @packagedata=cast(@xml as varbinary(max))  -- convert the xml back to binary
    UPDATE    sysssispackages SET packagedata = @packagedata WHERE (id= @planid)  -- update the plan

   end
    fetch next from PlansToFix into @planid  -- get the next plan

   end

   close PlansToFix
    deallocate PlansToFix
  ----- This will also handle the packages that have a tag such as 
    ----- <DTS:Property DTS:Name="ConnectionString">Data Source=servername;Integrated Security=SSPI;Connect Timeout=30;</DTS:Property>



   DECLARE @oldservername as varchar(max)
    SET @oldservername='<server name>\<instance name>'-- set the new server name to the current server name
    declare @newservername as varchar(max)
    set @newservername = @@servername
    declare @xml as varchar(max)
    declare @packagedata as varbinary(max)-- get all the plans that have the old server name in their connection string
    DECLARE PlansToFix Cursor FOR 
    SELECT id
    FROM sysssispackages
    WHERE (CAST(CAST(packagedata AS varbinary(MAX)) AS varchar(MAX)) LIKE '%Data Source=' + @oldservername + '%')

   OPEN PlansToFix
    declare @planid uniqueidentifier
    fetch next from PlansToFix into @planid 
    while (@@fetch_status<>-1) -- for each plan 
    begin
    if (@@fetch_status<>-2)
    begin
    select @xml=cast(cast(packagedata as varbinary(max)) as varchar(max)) 
    from sysssispackages where id= @planid -- get the plan's xml converted to an xml string
    declare @planname varchar(max)select @planname=[name] from sysssispackages where id= @planid -- get the plan name
    print 'Changing ' + @planname + ' server from ' + @oldservername + ' to ' + @newservername -- print out what change is happening
    set @xml=replace(@xml,'Data Source=' + @oldservername,'Data Source=' + @newservername) -- replace the old server name with the new server name in the connection string
    select @packagedata=cast(@xml as varbinary(max)) -- convert the xml back to binary
    UPDATE sysssispackages SET packagedata = @packagedata WHERE (id= @planid) -- update the plan
    end
    fetch next from PlansToFix into @planid -- get the next plan
    end
    close PlansToFix
    deallocate PlansToFix
share|improve this answer

I used this code from this answer to the Server Fault question Renamed a SQL Server, however maintenance plans still have old name:

SELECT  x.*,
        LocalServerConnectionString = cm.value('declare namespace DTS="www.microsoft.com/SqlServer/Dts";DTS:ObjectData[1]/DTS:ConnectionManager[1]/@DTS:ConnectionString', 'varchar(1000)')
FROM (
    SELECT  id, name, packageXML = CAST(CAST(packagedata AS VARBINARY(MAX)) AS XML)
    FROM dbo.sysssispackages
    WHERE id IN (SELECT id FROM dbo.sysmaintplan_plans)
) x
CROSS APPLY packageXML.nodes('declare namespace DTS="www.microsoft.com/SqlServer/Dts";/DTS:Executable/DTS:ConnectionManagers/DTS:ConnectionManager[@DTS:ObjectName="Local server connection"]') p(cm)

And to rename:

UPDATE dbo.sysssispackages SET packagedata = CAST(CAST(REPLACE(CAST(CAST(packagedata AS VARBINARY(MAX)) AS VARCHAR(MAX)), 'OldServerName', 'NewServerName') AS XML) AS VARBINARY(MAX))
WHERE id = 'package GUID'
share|improve this answer

When you rename an SQL Server (i.e. change the Windows NetBIOS name), you also need to carry out this small manual step inside SQL Server to rename it internally. Details in this MSKB article.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.