Imports abstract plans from a user table into an abstract plan group.
sp_import_qpgroup tab, usr, group
is the name of a table from which to copy the plans. You can specify a database name, but not an owner name, in the form dbname..tablename. The total length can be up to 255 characters long.
is the name of the user whose ID should be assigned to the abstract plans when they are imported.
is the name of the abstract plan group that contains the plans to be imported.
Copies plans from the table moveplans to the new_plans group, giving them the user ID for the database owner:
sp_import_qpgroup moveplans, dbo, new_plans
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
The permission checks for sp_import_qpgroup differ based on your granular permissions settings.
Granular permissions enabled |
With granular permissions enabled, you must be a user with manage abstract plans privilege. |
Granular permissions disabled |
With granular permissions disabled, you must be the datatype owner or a user with sa_role. |
Values in event and extrainfo columns from the sysaudits table are:
Event |
Audit option |
Command or access audited |
Information in extrainfo |
---|---|---|---|
38 |
exec_procedure |
Execution of a procedure |
|
Commands create plan
System procedures sp_copy_all_qplans, sp_copy_qplan, sp_drop_all_qplans, sp_drop_qpgroup, sp_export_qpgroup, sp_help_qpgroup