共用方式為


JobServer.ReassignJobsByLogin 方法

Changes ownership for any SQL Server Agent job currently owned by a SQL Server login.

命名空間:  Microsoft.SqlServer.Management.Smo.Agent
組件:  Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)

語法

'宣告
Public Sub ReassignJobsByLogin ( _
    oldLogin As String, _
    newLogin As String _
)
'用途
Dim instance As JobServer 
Dim oldLogin As String 
Dim newLogin As String

instance.ReassignJobsByLogin(oldLogin, _
    newLogin)
public void ReassignJobsByLogin(
    string oldLogin,
    string newLogin
)
public:
void ReassignJobsByLogin(
    String^ oldLogin, 
    String^ newLogin
)
member ReassignJobsByLogin : 
        oldLogin:string * 
        newLogin:string -> unit
public function ReassignJobsByLogin(
    oldLogin : String, 
    newLogin : String
)

參數

備註

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 the current connection must be a member of the fixed role sysadmin.

範例

使用 SQL Server Agent 排程自動管理工作

請參閱

參考

JobServer 類別

Microsoft.SqlServer.Management.Smo.Agent 命名空間

其他資源

自動化管理工作 (SQL Server Agent)

sp_delete_job (Transact-SQL)