System Stored Procedures (T-SQL)

Many administrative and informational activities in Microsoft® SQL Server™ can be performed through system stored procedures. The system stored procedures are grouped into these categories.

Category Description
Catalog Procedures Implements ODBC data dictionary functions and isolates ODBC applications from changes to underlying system tables.
Cursor Procedures Implements cursor variable functionality.
Distributed Queries Procedures Used to implement and manage Distributed Queries.
SQL Server Agent Procedures Used by SQL Server Agent to manage scheduled and event driven activities.
Replication Procedures Used to manage replication.
Security Procedures Used to manage security.
System Procedures Used for general maintenance of SQL Server.
Web Assistant Procedures Used by the Web Assistant.
General Extended Procedures Provides an interface from SQL Server to external programs for various maintenance activities.
SQL Mail Extended Procedures Used to perform e-mail operations from within SQL Server.
SQL Server Profiler Extended Procedures Used by SQL Server Profiler. To execute a SQL Server Profiler Extended Procedure against a local server through SQL Server Query Analyzer, use Windows NT Authentication. When using the shared memory network library, SQL Server does not support impersonation unless connected by using Windows NT Authentication.
OLE Automation Procedures Allows standard OLE automation objects to be used within a standard Transact-SQL batch.


Note Unless specifically documented otherwise, all system stored procedures return a value of 0, which indicates success. To indicate failure, a nonzero value is returned.


Catalog Procedures  
sp_column_privileges sp_special_columns
sp_columns sp_sproc_columns
sp_databases sp_statistics
sp_fkeys sp_stored_procedures
sp_pkeys sp_table_privileges
sp_server_info sp_tables

Cursor Procedures  
sp_cursor_list sp_describe_cursor_tables
sp_describe_cursor sp_describe_cursor_columns

SQL Server Agent Procedures  
sp_add_alert sp_help_jobschedule
sp_add_category sp_help_jobserver
sp_add_job sp_help_jobstep
sp_add_jobschedule sp_help_notification
sp_add_jobserver sp_help_operator
sp_add_jobstep sp_help_targetserver
sp_add_notification sp_help_targetservergroup
sp_add_operator sp_helphistory
sp_add_targetservergroup sp_helptask
sp_add_targetsvrgrp_member sp_manage_jobs_by_login
sp_addtask sp_msx_defect
sp_apply_job_to_targets sp_msx_enlist
sp_delete_alert sp_post_msx_operation
sp_delete_category sp_purge_jobhistory
sp_delete_job sp_purgehistory
sp_delete_jobschedule sp_reassigntask
sp_delete_jobserver sp_remove_job_from_targets
sp_delete_jobstep sp_resync_targetserver
sp_delete_notification sp_start_job
sp_delete_operator sp_stop_job
sp_delete_targetserver sp_update_alert
sp_delete_targetservergroup sp_update_category
sp_delete_targetsvrgrp_member sp_update_job
sp_droptask sp_update_jobschedule
sp_help_alert sp_update_jobstep
sp_help_category sp_update_notification
sp_help_downloadlist sp_update_operator
sp_help_job sp_update_targetservergroup
sp_help_jobhistory sp_updatetask

Replication Procedures  
sp_add_agent_parameter sp_dsninfo
sp_add_agent_profile sp_dumpparamcmd
sp_addarticle sp_enumcustomresolvers
sp_adddistpublisher sp_enumdsn
sp_adddistributiondb sp_enumfullsubscribers
sp_adddistributor sp_expired_subscription_cleanup
sp_addmergearticle sp_generatefilters
sp_addmergefilter sp_getmergedeletetype
sp_addmergepublication sp_get_distributor
sp_addmergepullsubscription sp_grant_publication_access
sp_addmergepullsubscription_agent sp_help_agent_default
sp_addmergesubscription sp_help_agent_parameter
sp_addpublication sp_help_agent_profile
sp_addpublication_snapshot sp_help_publication_access
sp_addpublisher70 sp_helparticle
sp_addpullsubscription sp_helparticlecolumns
sp_addpullsubscription_agent sp_helpdistpublisher
sp_addsubscriber sp_helpdistributiondb
sp_addsubscriber_schedule sp_helpdistributor
sp_addsubscription sp_helpmergearticle
sp_addsynctriggers sp_helpmergearticleconflicts
sp_addtabletocontents sp_helpmergeconflictrows
sp_article_validation sp_helpmergedeleteconflictrows
sp_articlecolumn sp_helpmergefilter
sp_articlefilter sp_helpmergepublication
sp_articlesynctranprocs sp_helpmergepullsubscription
sp_articleview sp_helpmergesubscription
sp_browsereplcmds sp_helppublication
sp_change_agent_parameter sp_helppullsubscription
sp_change_agent_profile sp_helpreplicationdboption
sp_changearticle sp_helpsubscriberinfo
sp_changedistpublisher sp_helpsubscription
sp_changedistributiondb sp_helpsubscription_properties
sp_changedistributor_password sp_link_publication
sp_changedistributor_property sp_mergedummyupdate
sp_changemergearticle sp_mergesubscription_cleanup
sp_changemergefilter sp_publication_validation
sp_changemergepublication sp_refreshsubscriptions
sp_changemergepullsubscription sp_reinitmergepullsubscription
sp_changemergesubscription sp_reinitmergesubscription
sp_changepublication sp_reinitpullsubscription
sp_changesubscriber sp_reinitsubscription
sp_changesubscriber_schedule sp_removedbreplication
sp_changesubstatus sp_replcmds
sp_change_subscription_properties sp_replcounters
sp_check_for_sync_trigger sp_repldone
sp_deletemergeconflictrow sp_replflush
sp_drop_agent_parameter sp_replicationdboption
sp_drop_agent_profile sp_replication_agent_checkup
sp_droparticle sp_replsetoriginator
sp_dropdistpublisher sp_replshowcmds
sp_dropdistributiondb sp_repltrans
sp_dropdistributor sp_revoke_publication_access
sp_dropmergearticle sp_script_synctran_commands
sp_dropmergefilter sp_scriptdelproc
sp_dropmergepublication sp_scriptinsproc
sp_dropmergepullsubscription sp_scriptmappedupdproc
sp_dropmergesubscription sp_scriptupdproc
sp_droppublication sp_subscription_cleanup
sp_droppullsubscription sp_table_validation
sp_dropsubscriber sp_update_agent_profile
sp_dropsubscription  

Security Procedures  
sp_addalias sp_droprole
sp_addapprole sp_droprolemember
sp_addgroup sp_dropserver
sp_addlinkedsrvlogin sp_dropsrvrolemember
sp_addlogin sp_dropuser
sp_addremotelogin sp_grantdbaccess
sp_addrole sp_grantlogin
sp_addrolemember sp_helpdbfixedrole
sp_addserver sp_helpgroup
sp_addsrvrolemember sp_helplinkedsrvlogin
sp_adduser sp_helplogins
sp_approlepassword sp_helpntgroup
sp_change_users_login sp_helpremotelogin
sp_changedbowner sp_helprole
sp_changegroup sp_helprolemember
sp_changeobjectowner sp_helprotect
sp_dbfixedrolepermission sp_helpsrvrole
sp_defaultdb sp_helpsrvrolemember
sp_defaultlanguage sp_helpuser
sp_denylogin sp_password
sp_dropalias sp_remoteoption
sp_dropapprole sp_revokedbaccess
sp_dropgroup sp_revokelogin
sp_droplinkedsrvlogin sp_setapprole
sp_droplogin sp_srvrolepermission
sp_dropremotelogin sp_validatelogins

System Procedures  
sp_add_data_file_recover_suspect_db sp_helpconstraint
sp_add_log_file_recover_suspect_db sp_helpdb
sp_addextendedproc sp_helpdevice
sp_addmessage sp_helpextendedproc
sp_addtype sp_helpfile
sp_addumpdevice sp_helpfilegroup
sp_altermessage sp_help_fulltext_catalogs
sp_autostats sp_help_fulltext_catalogs_cursor
sp_attach_db sp_help_fulltext_columns
sp_attach_single_file_db sp_help_fulltext_columns_cursor
sp_bindefault sp_help_fulltext_tables
sp_bindrule sp_help_fulltext_tables_cursor
sp_bindsession sp_helpindex
sp_certify_removable sp_helplanguage
sp_configure sp_helpserver
sp_create_removable sp_helpsort
sp_createstats sp_helptext
sp_cycle_errorlog sp_helptrigger
sp_datatype_info sp_indexoption
sp_dbcmptlevel sp_lock
sp_dboption sp_monitor
sp_delete_backuphistory sp_processmail
sp_depends sp_procoption
sp_detach_db sp_recompile
sp_dropdevice sp_refreshview
sp_dropextendedproc sp_rename
sp_dropmessage sp_renamedb
sp_droptype sp_serveroption
sp_executesql sp_setnetname
sp_getbindtoken sp_spaceused
sp_fulltext_catalog sp_tableoption
sp_fulltext_column sp_unbindefault
sp_fulltext_database sp_unbindrule
sp_fulltext_service sp_updatestats
sp_fulltext_table sp_validname
sp_help sp_who

Distributed Queries Procedures  
sp_addlinkedserver sp_indexes
sp_addlinkedsrvlogin sp_linkedservers
sp_catalogs sp_primarykeys
sp_column_privileges_ex sp_serveroption
sp_columns_ex sp_table_privileges_ex
sp_droplinkedsrvlogin sp_tables_ex
sp_foreignkeys  

Web Assistant Procedures  
sp_dropwebtask sp_makewebtask
sp_enumcodepages sp_runwebtask

General Extended Procedures  
xp_cmdshell xp_revokelogin
xp_enumgroups xp_sprintf
xp_findnextmsg xp_sqlinventory
xp_grantlogin xp_sscanf
xp_loginconfig xp_logevent
xp_logininfo  
xp_msver  
xp_sqlmaint  

SQL Mail Extended Procedures  
xp_deletemail xp_startmail
xp_readmail xp_stopmail
xp_sendmail xp_findnextmsg

SQL Server Profiler Extended Procedures  
xp_sqltrace xp_trace_getuserfilter
xp_trace_addnewqueue xp_trace_getwritefilter
xp_trace_deletequeuedefinition xp_trace_loadqueuedefinition
xp_trace_destroyqueue xp_trace_pausequeue
xp_trace_enumqueuedefname xp_trace_restartqueue
xp_trace_enumqueuehandles xp_trace_savequeuedefinition
xp_trace_eventclassrequired xp_trace_setappfilter
xp_trace_flushqueryhistory xp_trace_setconnectionidfilter
xp_trace_generate_event xp_trace_setcpufilter
xp_trace_getappfilter xp_trace_setdbidfilter
xp_trace_getconnectionidfilter xp_trace_setdurationfilter
xp_trace_getcpufilter xp_trace_seteventclassrequired
xp_trace_getdbidfilter xp_trace_seteventfilter
xp_trace_getdurationfilter xp_trace_sethostfilter
xp_trace_geteventfilter xp_trace_sethpidfilter
xp_trace_geteventnames xp_trace_setindidfilter
xp_trace_getevents xp_trace_setntdmfilter
xp_trace_gethostfilter xp_trace_setntnmfilter
xp_trace_gethpidfilter xp_trace_setobjidfilter
xp_trace_getindidfilter xp_trace_setqueryhistory
xp_trace_getntdmfilter xp_trace_setqueueautostart
xp_trace_getntnmfilter xp_trace_setqueuecreateinfo
xp_trace_getobjidfilter xp_trace_setqueuedestination
xp_trace_getqueueautostart xp_trace_setreadfilter
xp_trace_getqueuedestination xp_trace_setserverfilter
xp_trace_getqueueproperties xp_trace_setseverityfilter
xp_trace_getreadfilter xp_trace_setspidfilter
xp_trace_getserverfilter xp_trace_setsysobjectsfilter
xp_trace_getseverityfilter xp_trace_settextfilter
xp_trace_getspidfilter xp_trace_setuserfilter
xp_trace_getsysobjectsfilter xp_trace_setwritefilter
xp_trace_gettextfilter  

OLE Automation Extended Stored Procedures  
sp_OACreate sp_OAMethod
sp_OADestroy sp_OASetProperty
sp_OAGetErrorInfo sp_OAStop
sp_OAGetProperty Object Hierarchy Syntax

API System Stored Procedures

Users running SQL Server Profiler against ADO, OLE DB, ODBC, and DB-Library applications may notice the use of system stored procedures that are not covered in the Transact-SQL Reference. These stored procedures are used by the Microsoft OLE DB Provider for SQL Server, the SQL Server ODBC driver, and the DB-Library dynamic-link library (DLL) to implement the functionality of a database API. These stored procedures are simply the mechanism the provider or drivers use to communicate user requests to SQL Server. They are intended only for the internal use of the OLE DB Provider for SQL Server, the SQL Server ODBC driver, and the DB-Library DLL. Calling them explicitly from a SQL Server application is not supported.

The complete functionality from these stored procedures is made available to SQL Server applications through the API functions they support. For example, the cursor functionality of the sp_cursor system stored procedures is made available to OLE DB applications through the OLE DB API cursor properties and methods, to ODBC applications through the ODBC cursor attributes and functions, and to DB-Library applications through the DB-Library Cursor Library.

These system stored procedures support the cursor functionality of ADO, OLE DB, ODBC, and the DB-Library Cursor Library:

sp_cursor sp_cursorclose sp_cursorexecute
sp_cursorfetch sp_cursoropen sp_cursoroption
sp_cursorprepare sp_cursorunprepare  

These system stored procedures support the prepare/execute model of executing Transact-SQL statements in ADO, OLE DB, and ODBC:

sp_execute sp_prepare sp_unprepare

The sp_createorphan and sp_droporphans stored procedures are used for ODBC ntext, text, and image processing.

The sp_reset_connection stored procedure is used by SQL Server to support remote stored procedure calls in a transaction.

The sp_sdidebug stored procedure is used by SQL Server for debugging Transact-SQL statements.

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.