sp_import_qpgroup

Imports abstract plans from a user table into an abstract plan group.

Syntax

sp_import_qpgroup tab, usr, group

Parameters

Examples

Usage

There are additional considerations when using sp_import_qpgroup:
  • sp_import_qpgroup copies plans from a user table to an abstract plan group in sysqueryplans. With sp_export_qpgroup, it can be used to copy abstract plan groups between servers and databases, or to copy plans belonging to one user and assign them the ID of another user.

  • sp_import_qpgroup creates the abstract plan group if it does not exist when the procedure is executed.

  • If an abstract plan group exists when sp_import_qpgroup is executed, it cannot contain any plans for the specified user. sp_import_qpgroup does not check the query text to determine whether queries already exist in the group. If you need to import plans for a user into a group where some plans for the user already exist:
    • Use sp_import_qpgroup to import the plans into a new plan group.

    • Use sp_copy_all_qplans to copy the plans from the newly-created group to the destination group. sp_copy_all_qplans does check queries to be sure that no duplicate plans are created.

    • If you no longer need the group you created for the import, drop the plans in the group with sp_copy_all_qplans, then drop the group with sp_drop_qpgroup.

  • To create an empty table in order to bulk copy abstract plans, use:
    select * into load_table 
    from sysqueryplans
    where 1 = 2

See also create plan in Reference Manual: Commands.

Permissions

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

SettingDescription
Enabled

With granular permissions enabled, you must be a user with manage abstract plans privilege.

Disabled

With granular permissions disabled, you must be the datatype owner or a user with sa_role.

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_copy_all_qplans
sp_copy_qplan
sp_drop_all_qplans
sp_drop_qpgroup
sp_export_qpgroup
sp_help_qpgroup