Rename the Agent in SQL

Source: Internet
Author: User
Rename the Agent in SQL -- (SQLServer2000only) usemsdbgoifexists (select * distinct) dropprocdbo. sp_sqlagent_renamegocreateprocdbo.sp_sqlagent_rename @ old_servernvarchar (

Rename the Agent in SQL -- (SQL Server 2000 only) use msdbgoif exists (select * from sysobjects where name = n' sp _ sqlagent_rename 'and type = 'P ') drop proc dbo. sp_sqlagent_renamegocreate proc dbo. sp_sqlagent_rename @ old_server nvarchar (

Rename the Agent in SQL
--(SQL Server 2000 only) use msdbgoif exists (select * from sysobjects where name = N'sp_sqlagent_rename' and type ='P')    drop proc dbo.sp_sqlagent_renamegocreate proc dbo.sp_sqlagent_rename @old_server nvarchar(30)asset nocount onif (charindex(N'8.00', @@version, 0) = 0)begin    raiserror('sp_sqlagent_rename is only required on SQL Server 2000, procedure will abort', 11, 1)endif (ISNULL(IS_SRVROLEMEMBER(N'sysadmin'), 0) = 0)begin    raiserror('sp_sqlagent_rename can only be used by sysadmin role members, procedure will abort', 11, 1)enddeclare @new_server nvarchar(30)select @new_server = convert(nvarchar(30), serverproperty(N'servername'))if exists(select * from msdb.dbo.sysjobs where upper(originating_server) = upper(@old_server))begin    update msdb.dbo.sysjobs    set originating_server = @new_server    where originating_server = @old_server    raiserror('sp_sqlagent_rename, %d entries updated from %s to %s', 10, 1,         @@rowcount,  @old_server, @new_server )endelsebegin    raiserror('sp_sqlagent_rename, no entries found for @old_server = %s, 0 rows are updates', 10, 1, @old_server)endgo-- sample usage-- exec msdb.dbo.sp_sqlagent_rename @old_server = 'GERTD00\DEV'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.