sys.sp_dbcmptlevel
Stored Procedures

Sets certain database behaviors to be compatible with the specified version of SQL Server.

#stored-procedure
sys.sp_dbfixedrolepermission
Stored Procedures

Displays the permissions of a fixed database role. information in SQL Server 2000 (8.x). The output doesn't reflect the changes to the permissions hierarchy that were implemented in SQL Server 2005 (9.x). For more information, see , which shows a list of fixed database roles and its corresponding permissions.

#stored-procedure
sys.sp_dbmmonitoraddmonitoring
Stored Procedures

Creates a database mirroring monitor job that periodically updates the mirroring status for every mirrored database on the server instance. Specifies the interval between updates in minutes. , with a default of This value can be from 1 to 120 minutes. If update period is set too low, the response time might increase for clients.

#stored-procedure
sys.sp_dbmmonitorchangealert
Stored Procedures

Adds or changes warning threshold for a specified mirroring performance metric. Specifies the database for which to add or change the specified warning threshold. An integer value that identifies the warning to be added or changed.

#stored-procedure
sys.sp_dbmmonitorchangemonitoring
Stored Procedures

Changes the value of a database mirroring monitoring parameter. Specifies the identifier of the parameter to be changed. Currently, only the following parameter is available: The number of minutes between updates to the database mirroring status table. The default Specifies the new value for the parameter that is being changed.

#stored-procedure
sys.sp_dbmmonitordropalert
Stored Procedures

Drops the warning for a specified performance metric, by setting the threshold to Specifies the database for which to drop the specified warning threshold. An integer value that identifies the warning to be dropped. Specifies the number of minutes worth of transactions that can accumulate in the send queue before a warning is generated on the principal server instan

#stored-procedure
sys.sp_dbmmonitordropmonitoring
Stored Procedures

Stops and deletes the mirroring monitor job for all the databases on the server instance. fixed server role, or execute permission directly on this The following example drops database mirroring monitoring on all of the mirrored databases

#stored-procedure
sys.sp_dbmmonitorhelpalert
Stored Procedures

Returns information about warning thresholds on one or all of several key database mirroring An integer value that identifies the warning to be returned. If this argument is omitted, all the warnings are returned, but not the retention period. To return a specific warning, specify one of the following values: Specifies the number of minutes worth of transactions t

#stored-procedure
sys.sp_dbmmonitorhelpmonitoring
Stored Procedures

Returns the current update period. Returns the current update period, that is, the number of minutes between updates of database mirroring status table. This value ranges from 1 to 120 minutes. fixed server role, or execute permission directly on this The following example returns the current update period.

#stored-procedure
sys.sp_dbmmonitorresults
Stored Procedures

Returns status rows for a monitored database from the status table in which database mirroring monitoring history is stored, and allows you to choose whether the procedure obtains the latest status beforehand. Specifies the database for which to return mirroring status. Specifies the quantity of rows returned. , and can be one of these values.

#stored-procedure
sys.sp_dbmmonitorupdate
Stored Procedures

Updates the database mirroring monitor status table by inserting a new table row for each mirrored database, and truncates rows older than the current retention period. The default retention period is seven days (168 hours). When evaluates the performance metrics.

#stored-procedure
sys.sp_dbremove
Stored Procedures

Removes a database and all files associated with that database.

#stored-procedure
sys.sp_defaultdb
Stored Procedures

Changes the default database for a SQL Server login. Server login or a Windows user or group. If a login for the Windows user or group doesn't exist in SQL Server, it's automatically added.

#stored-procedure
sys.sp_defaultlanguage
Stored Procedures

Changes the default language of for a SQL Server login. Server login, or a Windows user or group. The default language of the login. must be a valid language on the server. If server default language (defined by the Changing the server default language doesn't change the default language for existing logins. This feature will be removed in a future version of SQL Se

#stored-procedure
sys.sp_delete_alert
Stored Procedures

Removing an alert also removes any notifications associated with the alert. permissions on this procedure, but these permissions might be overridden during a SQL Server upgrade.

#stored-procedure
sys.sp_delete_backup
Stored Procedures

2016 (13.x) and later versions Deletes all snapshots and the backup file that comprise a snapshot backup set from the specified database. This system stored procedure is the only recommended method for managing snapshot backup sets. For more information, see The URL of the backup to be deleted, which deletes all snapshots comprising the specified backup s

#stored-procedure
sys.sp_delete_backup_file_snapshot
Stored Procedures

2016 (13.x) and later versions Deletes a specified backup snapshot from the specified database. Use this system stored procedure in conjunction with the identify and delete orphaned backup snapshots. For more information, see Backups for Database Files in Azure The name of the database containing the snapshot to be deleted, provided as a Unicode string. T

#stored-procedure
sys.sp_delete_backuphistory
Stored Procedures

Reduces the size of the backup and restore history tables by deleting the entries for backup sets older than the specified date. More rows are added to the backup and restore history tables after each backup or restore operation is performed; therefore, we recommend that you The oldest date retained in the backup and restore history tables.

#stored-procedure
sys.sp_delete_category
Stored Procedures

Removes the specified category of jobs, alerts, or operators from the current server. , with no default, and must be one of these The name of the category to be removed.

#stored-procedure
sys.sp_delete_database_backuphistory
Stored Procedures

Deletes information about the specified database from the backup and restore history tables. Specifies the name of the database involved in backup and restore operations. , with no default. must be run from the This stored procedure affects the following tables:

#stored-procedure
sys.sp_delete_job
Stored Procedures

Deletes a job from the SQL Server Agent service. The identification number of the job to be deleted. must be specified; both can't be specified.

#stored-procedure
sys.sp_delete_jobschedule
Stored Procedures

Deletes a schedule for a job in the SQL Server Agent service. is provided for backward compatibility only. This feature will be removed in a future version of SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Job schedules can now be managed independently of jobs. To remove a schedule from a job, doesn't support schedules

#stored-procedure
sys.sp_delete_jobserver
Stored Procedures

Removes the specified target server. The identification number of the job from which the specified target server will be removed. must be specified, but both can't be specified.

#stored-procedure
sys.sp_delete_jobstep
Stored Procedures

Removes a job step from a job in the SQL Server Agent service. The identification number of the job from which the step will be removed. must be specified; both can't be specified.

#stored-procedure
sys.sp_delete_jobsteplog
Stored Procedures

Removes all SQL Server Agent job step logs that are specified with the arguments. Use this stored procedure to maintain the The job identification number for the job that contains the job step log to be removed. must be specified, but both can't be specified. must be specified, but both can't be specified.

#stored-procedure
sys.sp_delete_log_shipping_alert_job
Stored Procedures

Removes an alert job from the log shipping monitor server if the job exists and there are no more primary or secondary databases to be monitored. fixed server role can run this procedure.

#stored-procedure
sys.sp_delete_log_shipping_primary_database
Stored Procedures

This stored procedure removes log shipping of primary database including backup job, local and remote history. Only use this stored procedure after you remove the secondary databases The name of the log shipping primary database. Identified for informational purposes only. Not supported.

#stored-procedure
sys.sp_delete_log_shipping_primary_secondary
Stored Procedures

Removes the entry for a secondary database on the primary server.

#stored-procedure
sys.sp_delete_log_shipping_secondary_database
Stored Procedures

fixed server role can run this procedure. About log shipping (SQL Server) System stored procedures (Transact-SQL)

#stored-procedure
sys.sp_delete_log_shipping_secondary_primary
Stored Procedures

removes the information about the specified primary server from the secondary server, and removes the copy job and restore job from the The name of the primary instance of the SQL Server Database Engine in the log shipping The name of the database on the primary server.

#stored-procedure
sys.sp_delete_maintenance_plan
Stored Procedures

Deletes the specified maintenance plan. This feature will be removed in a future version of SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Specifies the ID of the maintenance plan to be deleted. must be run from the This stored procedure is used with database maintenance plans.

#stored-procedure
sys.sp_delete_maintenance_plan_db
Stored Procedures

Disassociates the specified maintenance plan from the specified database. This feature will be removed in a future version of SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Specifies the maintenance plan ID. Specifies the database name to be deleted from the maintenance plan. This stored

#stored-procedure
sys.sp_delete_maintenance_plan_job
Stored Procedures

Disassociates the specified maintenance plan from the specified job. This feature will be removed in a future version of SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Specifies the ID of the maintenance plan. Specifies the ID of the job with which the maintenance plan is associated. Thi

#stored-procedure
sys.sp_delete_notification
Stored Procedures

Removes a SQL Server Agent notification definition for a specific alert and operator.

#stored-procedure
sys.sp_delete_operator
Stored Procedures

Removes an operator.

#stored-procedure
sys.sp_delete_proxy
Stored Procedures

Removes the specified proxy. The proxy identification number of the proxy to remove. , with a default of The name of the proxy to remove.

#stored-procedure
sys.sp_delete_schedule
Stored Procedures

The schedule identification number of the schedule to delete. must be specified, but both can't be specified.

#stored-procedure
sys.sp_delete_targetserver
Stored Procedures

Removes the specified server from the list of available target servers.

#stored-procedure
sys.sp_delete_targetservergroup
Stored Procedures

Deletes the specified target server group.

#stored-procedure
sys.sp_delete_targetsvrgrp_member
Stored Procedures

Removes a target server from a target server group.

#stored-procedure
sys.sp_deletemergeconflictrow
Stored Procedures

Deletes rows from a conflict table or the table. This stored procedure is executed at the computer where the conflict table is stored, in any database.

#stored-procedure
sys.sp_deletepeerrequesthistory
Stored Procedures

Deletes history related to a publication status request, which includes the request history ) as well as the response history ( executed on the publication database at a Publisher participating in a Peer-to-Peer replication topology. For more information, see Peer-to-Peer - Transactional Replication Name of the publication for which the status request was made. Spec

#stored-procedure
sys.sp_deletetracertokenhistory
Stored Procedures

Removes tracer token records from the This stored procedure is executed at the Publisher on the publication database or at the Distributor on the distribution database.

#stored-procedure
sys.sp_denylogin
Stored Procedures

Prevents a Windows user or Windows group from connecting to an instance of SQL Server.

#stored-procedure
sys.sp_depends
Stored Procedures

Displays information about database object dependencies, such as the views and procedures that depend on a table or view, and the tables and views that are depended on by the view or procedure. References to objects outside the current database aren't reported. This feature will be removed in a future version of SQL Server. Avoid using this feature in new developmen

#stored-procedure
sys.sp_describe_cursor
Stored Procedures

A data type for variables or stored procedure OUTPUT parameters that contain a reference to a The operations that can reference variables and parameters having a @local_variable @local_variable The OPEN, FETCH, CLOSE, and DEALLOCATE cursor statements. Stored procedure output parameters. The CURSOR_STATUS function. syste

#stored-procedure
sys.sp_describe_cursor_columns
Stored Procedures

A data type for variables or stored procedure OUTPUT parameters that contain a reference to a The operations that can reference variables and parameters having a @local_variable @local_variable The OPEN, FETCH, CLOSE, and DEALLOCATE cursor statements. Stored procedure output parameters. The CURSOR_STATUS function. syste

#stored-procedure
sys.sp_describe_cursor_tables
Stored Procedures

A data type for variables or stored procedure OUTPUT parameters that contain a reference to a The operations that can reference variables and parameters having a @local_variable @local_variable The OPEN, FETCH, CLOSE, and DEALLOCATE cursor statements. Stored procedure output parameters. The CURSOR_STATUS function. syste

#stored-procedure
sys.sp_describe_first_result_set
Stored Procedures

Position of this column in ORDER BY list Returns NULL if the column does not appear in the ORDER BY list or if the ORDER BY list cannot be uniquely Length of the ORDER BY list. Returns NULL if there is no ORDER BY list or if the ORDER BY list cannot be uniquely determined. Note that this value will be the same for all rows returned by sp_describe_first_result_set. If the ordinal_in_order_by_list i

#stored-procedure
sys.sp_describe_parameter_encryption
Stored Procedures

2016 (13.x) and later Analyzes the specified Transact-SQL statement and its parameters, to determine which parameters correspond to database columns that are protected by using the Always Encrypted feature. Returns encryption metadata for the parameters that correspond to encrypted columns. One or more Transact-SQL statements.

#stored-procedure
sys.sp_describe_undeclared_parameters
Stored Procedures

For internal use. Not nullable. always returns status of zero. The most common use is when an application is given a Transact-SQL statement that might contain parameters and must process them in some way. An example is a user interface (such ) where the user provides a query with ODBC parameter syntax. The application must dynamically discover the number of parameters and prompt the user for Anoth

#stored-procedure
sys.sp_detach_db
Stored Procedures

Detaches a database that is currently not in use from a server instance and, optionally, runs on all tables before detaching. For a replicated database to be detached, it must be unpublished. For more information, see section later in this article.

#stored-procedure
sys.sp_detach_schedule
Stored Procedures

Removes an association between a schedule and a job. The job identification number of the job to remove the schedule from. must be specified, but both can't be specified.

#stored-procedure
sys.sp_disable_event_stream
Stored Procedures

Disables change event streaming at the database level for the current database context, including all associated tables. What is change event streaming (preview)? SQL Server 2025 (17.x) and Azure SQL Database. server role membership can execute this procedure. What is change event streaming (preview)? Configure change event streaming (preview) Change event streaming

#stored-procedure
sys.sp_drop_agent_parameter
Stored Procedures

Drops one or all parameters from a profile in the table. This stored procedure is executed at the Distributor where the agent is running, on any database. The ID of the profile for which a parameter is to be dropped. , with no default.

#stored-procedure
sys.sp_drop_agent_profile
Stored Procedures

table. This stored procedure is executed at the The ID of the profile to be dropped. is used in all types of replication.

#stored-procedure
sys.sp_drop_event_stream_group
Stored Procedures

Drops a stream event group for the Server 2025 (17.x) and Azure SQL Database. Specifies the name of the event stream group you want to drop. , with no default, and can't be server role membership can execute this procedure. Change event streaming is currently in Azure SQL Database (preview feature database scoped configuration not required).

#stored-procedure
sys.sp_drop_trusted_assembly
Stored Procedures

2017 (14.x) and later Drops an assembly from the list of trusted assemblies on the server. The SHA2_512 hash value of the assembly to drop from the list of trusted assemblies for the server. Trusted assemblies might load when CLR strict security is enabled, even if the assembly is unsigned or the database isn't marked as trustworthy. This procedure remove

#stored-procedure
sys.sp_dropanonymousagent
Stored Procedures

Drops an anonymous agent for replication monitoring at the distributor from the Publisher. This stored procedure is executed at the Publisher on any database. The global identifier for an anonymous subscription. default. This identifier can be retrieved at the Subscriber using field of the returned result set is this global identifier. The type of subscription.

#stored-procedure
sys.sp_dropapprole
Stored Procedures

Removes an application role from the current database. The application role to remove. , with no default. in the current database. can only be used to remove application roles. If a role owns any securables, the role can't be dropped. Before dropping an application role that owns securables, you must first transfer ownership of the securables, or drop them.

#stored-procedure
sys.sp_droparticle
Stored Procedures

Drops an article from a snapshot or transactional publication. An article can't be removed if one or more subscriptions to it exist. This stored procedure is executed at the Publisher on the The name of the publication that contains the article to be dropped.

#stored-procedure
sys.sp_dropdevice
Stored Procedures

Drops a database device or backup device from a SQL Server Database Engine instance, The logical name of the database device or backup device as listed in Specifies whether the physical backup device file should be deleted. , the physical backup device disk file is deleted.

#stored-procedure
sys.sp_dropdistpublisher
Stored Procedures

Drops a distribution Publisher. This stored procedure is executed at the Distributor on any checks that the Publisher has uninstalled the server as , replication verifies that the remote Publisher has uninstalled the local server as the Distributor. If the Publisher is local, replication verifies that there are no publication or Using a custom port for the SQL Serve

#stored-procedure
sys.sp_dropdistributiondb
Stored Procedures

Drops a distribution database. Drops the physical files used by the database if they aren't used by another database. This stored procedure is executed at the Distributor on any database. The database to drop. , with no default. Specifies whether this node was previously part of an availability group for the distribution @former_ag_seconda

#stored-procedure
sys.sp_dropdistributor
Stored Procedures

Uninstalls the Distributor. This stored procedure is executed at the Distributor on any database except the distribution database. Indicates whether to check for dependent objects before dropping the Distributor. checks to make sure that all publishing and distribution objects were dropped, in addition to the Distributor.

#stored-procedure
sys.sp_dropdynamicsnapshot_job
Stored Procedures

Removes a filtered data snapshot job for a publication with parameterized row filters. This stored procedure is executed at the Publisher on the publication database. When the job is deleted, all of the related data is deleted from the The name of the publication from which the filtered data snapshot job is being removed.

#stored-procedure
sys.sp_dropextendedproc
Stored Procedures

Drops an extended stored procedure.

#stored-procedure
sys.sp_droplinkedsrvlogin
Stored Procedures

Removes an existing mapping between a login on the local server running SQL Server, and a login on the linked server.

#stored-procedure
sys.sp_droplogin
Stored Procedures

Removes a SQL Server login, which prevents access to an instance of SQL Server under that The login to be removed. , with no default. exist in SQL Server. This feature will be removed in a future version of SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

#stored-procedure
sys.sp_dropmergealternatepublisher
Stored Procedures

Removes an alternate Publisher from a merge publication. This stored procedure is executed at the Subscriber on the subscription database.

#stored-procedure
sys.sp_dropmergearticle
Stored Procedures

Removes an article from a merge publication. This stored procedure is executed at the Publisher on the publication database.

#stored-procedure
sys.sp_dropmergefilter
Stored Procedures

drops all the merge filter columns defined on the merge filter that is to be dropped. This stored procedure is executed at the Publisher on the The name of the filter to be dropped.

#stored-procedure
sys.sp_dropmergepartition
Stored Procedures

Removes a partition for a parameterized row filter from a publication. This stored procedure is executed at the Publisher on the publication database. This stored procedure also removes the corresponding snapshot job and snapshot files for the partition. function at the Subscriber used to define the partition. function at the Subscrib

#stored-procedure
sys.sp_dropmergepublication
Stored Procedures

Drops a merge publication and its associated Snapshot Agent. All subscriptions must be dropped before dropping a merge publication. The articles in the publication are dropped automatically. This stored procedure is executed at the Publisher on the publication database.

#stored-procedure
sys.sp_dropmergepullsubscription
Stored Procedures

Drops a merge pull subscription. This stored procedure is executed at the Subscriber on the to remove subscriptions to all publications.

#stored-procedure
sys.sp_dropmergesubscription
Stored Procedures

Drops a subscription to a merge publication and its associated Merge Agent. This stored procedure is executed at the Publisher on the publication database. already exist and conform to the rules for The name of the subscription database.

#stored-procedure
sys.sp_dropmessage
Stored Procedures

Drops a specified user-defined error message from an instance of the SQL Server Database Engine. User-defined messages can be viewed using the user-defined message that's a message number greater than The language of the message to drop.

#stored-procedure
sys.sp_droppublication
Stored Procedures

Drops a publication and its associated Snapshot Agent. All subscriptions must be dropped before dropping a publication. The articles in the publication are dropped automatically. This stored procedure is executed at the Publisher on the publication database.

#stored-procedure
sys.sp_droppullsubscription
Stored Procedures

Drops a subscription at the current database of the Subscriber. This stored procedure is executed at the Subscriber on the pull subscription database. dropped at all the Publishers.

#stored-procedure
sys.sp_dropremotelogin
Stored Procedures

Removes a remote login mapped to a local login used to execute remote stored procedures against the local server running SQL Server.

#stored-procedure
sys.sp_droprole
Stored Procedures

Removes a database role from the current database.

#stored-procedure
sys.sp_droprolemember
Stored Procedures

Removes a security account from a SQL Server role in the current database. Syntax for SQL Server and Azure SQL Edge. Syntax for Azure Synapse Analytics and Analytics Platform System (PDW). This feature will be removed in a future version of SQL Server. Avoid using this feature in new development work, and plan to modify applications t

#stored-procedure
sys.sp_dropserver
Stored Procedures

Removes a server from the list of known remote and linked servers on the local instance of SQL The server to be removed. , with no default. Indicates that related remote and linked server logins for must also be removed if , with a default of An error is returned if you run on a server with associated remote and linked server login entries

#stored-procedure
sys.sp_dropsrvrolemember
Stored Procedures

Removes a SQL Server login, a Windows user, or Windows group, from a fixed server role.

#stored-procedure
sys.sp_dropsubscriber
Stored Procedures

Removes the Subscriber designation from a registered server. This stored procedure is executed at the Publisher on the publication database.

#stored-procedure
sys.sp_dropsubscription
Stored Procedures

Drops subscriptions to a particular article, publication, or set of subscriptions on the Publisher. This stored procedure is executed at the Publisher on the publication database.

#stored-procedure
sys.sp_droptype
Stored Procedures

Deletes an alias data type from The name of an alias data type that you own. , with no default. alias data type can't be dropped if tables or other database objects reference it. An alias data type can't be dropped if the alias data type is used within a table definition or if a rule or default is bound to it.

#stored-procedure
sys.sp_dropuser
Stored Procedures

Removes a database user from the current database. provides compatibility with earlier versions of SQL Server.

#stored-procedure
sys.sp_dsninfo
Stored Procedures

Returns ODBC or OLE DB data source information from the Distributor associated with the current server. This stored procedure is executed at the Distributor on any database.

#stored-procedure
sys.sp_enable_event_stream
Stored Procedures

Enables change event streaming at the database level for the current database context. change event streaming (preview)? was introduced in SQL Server 2025 (17.x) and Azure SQL server role membership can execute this procedure. Change event streaming is currently in Azure SQL Database (preview feature database scoped configuration not required).

#stored-procedure
sys.sp_enclave_send_keys
Stored Procedures

2019 (15.x) and later - Windows only Sends columns encryption keys, defined in the database, to the server-side secure enclave used Always Encrypted with secure enclaves only sends only the keys that are enclave-enabled and encrypt columns that use randomized encryption and have indexes. For a regular user query, a client driver provides the enclave with the keys needed for computations

#stored-procedure
sys.sp_enum_login_for_proxy
Stored Procedures

Lists associations between security principals and proxies.

#stored-procedure
sys.sp_enum_proxy_for_subsystem
Stored Procedures

Lists permissions for SQL Server Agent proxies to access subsystems. The identification number of the proxy to list information for.

#stored-procedure
sys.sp_enumcustomresolvers
Stored Procedures

Returns a list of all available business logic handlers and custom resolvers registered at the Distributor. This stored procedure is executed at the Publisher on any database.

#stored-procedure
sys.sp_enumdsn
Stored Procedures

Returns a list of all defined ODBC and OLE DB data source names for a server running under a specific Windows user account. This stored procedure is executed at the Publisher on any Description of the data source.

#stored-procedure
sys.sp_enumeratependingschemachanges
Stored Procedures

Returns a list of all pending schema changes. This stored procedure can be used with , which enables an administrator to skip selected pending schema changes so that they aren't replicated. This stored procedure is executed at the Publisher on the publication database. The lowest number schema change to include in the result set.

#stored-procedure
sys.sp_estimate_data_compression_savings
Stored Procedures

Returns the current size of the requested object and estimates the object size for the requested compression state. Compression can be evaluated for whole tables or parts of tables. This includes heaps, clustered indexes, nonclustered indexes, columnstore indexes, indexed views, and table and index partitions.

#stored-procedure
sys.sp_execute
Stored Procedures

Executes a prepared Transact-SQL statement using a specified handle and optional parameter in a tabular data stream (TDS) packet. Signifies the use of extra parameters.

#stored-procedure
sys.sp_execute_external_script
Stored Procedures

2016 (13.x) and later stored procedure executes a script provided as an input argument to the procedure, and is used with For Machine Learning Services, are supported languages. For Language Extensions, Java is supported but must be defined with , you must first install Machine Learning Services or Language Extensions. For more information, see Install SQL Server Machine Learning Servic

#stored-procedure
sys.sp_executesql
Stored Procedures

A placeholder for the values of extra parameters. Values can only be constants or variables. Values can't be more complex expressions such as functions, or expressions built by using (success) or non-zero (failure). Returns the result sets from all the SQL statements built into the SQL string. parameters must be entered in the specific order as described in the section earlier in this article. If

#stored-procedure