共用方式為


ReAssignJobsByLogin Method

未來的 Microsoft SQL Server 版本將移除這項功能。請避免在新的開發工作中使用這項功能,並規劃修改目前使用這項功能的應用程式。

The ReAssignJobsByLogin method changes ownership for any SQL Server Agent jobs currently owned by a Microsoft SQL Server login.

語法

object
.ReAssignJobsByLogin(
OldLogin
, 
NewLogin
)

Parts

  • object
    Expression that evaluates to an object in the Applies To list.

  • OldLogin
    String that specifies a login currently owning jobs.

  • NewLogin
    String that specifies a login with job creation rights. The login specified will receive ownership.

Prototype (C/C++)

HRESULT ReAssignJobsByLogin(
SQLDMO_LPCSTR szOldLogin,
SQLDMO_LPCSTR szNewLogin);

備註

By default, any SQL Server login has membership, through the user guest, in the public role of the system database maintaining SQL Server Agent jobs (msdb). When a SQL Server user is created in msdb, jobs created by the user mapping the login are owned by the login, not the user.

Reassigning SQL Server Agent job ownership by using the ReAssignJobsByLogin method requires appropriate permission. The SQL Server login used for SQLServer object connection must be a member of the fixed role sysadmin.

Applies To: