sp_setpsexe

Sets custom execution attributes for a session while the session is active.

Syntax

sp_setpsexe spid, exeattr, value

Parameters

Examples

Usage

There are additional considerations when using sp_setpsexe:
  • Execution attribute values specified with sp_setpsexe are valid for the current session only and do not apply after the session terminates.

  • Use sp_setpsexe with caution or it can result in degraded performance. Changing attributes “on the fly”, using sp_setpsexe, can help if the process is not getting CPU time; however, if the performance problem is due to something else, such as locks, changing execution attributes could make the problem worse.

  • Because you can only set execution attributes for sessions, sp_setpsexe cannot be set for a worker process spid.

  • Except for the housekeeper spid, you cannot set execution attributes for system spids.

  • sp_setpsexe does not work if there are no online engines in the associated engine group.

Permissions

The permission checks for sp_setpsexe differ based on your granular permissions settings.

SettingDescription
Enabled

With granular permissions enabled, you must be a user with manage any execution class privilege.

Any user can execute sp_setpsexe to lower the priority of a process owned by that user.

Disabled

With granular permissions disabled, you must be a user with sa_role.

Any user can execute sp_setpsexe to lower the priority of a process owned by that user.

Auditing

Values in event and extrainfo columns from the sysaudits table are:

InformationValues
Event

38

Audit option

exec_procedure

Command or access audited

Execution of a procedure

Information in extrainfo
  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – All input parameters

  • Proxy information – Original login name, if set proxy in effect

Related reference
sp_addexeclass
sp_bindexeclass
sp_dropexeclass
sp_showexeclass