SatishKartan

Blog Post

SQL Server System Stored Procedures

  • By Satish Kartan
  • 16 Mar, 2018

System Stored Procedures System stored procedures are packaged with SQL Server. Many procedures are used to administer SQL Server, but some are utilities that can be profitablly used by developers. They are global, and can be called from any database application without their fully qualified name. (They are all owned by dbo.) . They are all stored in the Master database, and have the prefix sp_. This is a reason why it is considered unwise to name local stored procedures with the sp_ prefix. They can be read by viewing their properties in the Query Analyzer.

 

The system-stored procedures are grouped into these categories.

 

Category

Description

 

Active Directory Procedures

Used to register instances of SQL Server and SQL Server databases in Microsoft Windows® 2000 Active Directory™.

 

Catalog Procedures

Implements ODBC data dictionary functions and isolates ODBC applications from changes to underlying system tables.

 

Cursor Procedures

Implements cursor variable functionality.

 

Database Maintenance Plan Procedures

Used to set up core maintenance tasks necessary to ensure database performance.

 

Distributed Queries Procedures

Used to implement and manage Distributed Queries.

 

Full-Text Search Procedures

Used to implement and query full-text indexes.

 

Log Shipping Procedures

Used to configure and manage log shipping.

 

OLE Automation Procedures

Allows standard OLE automation objects to be used within a standard Transact-SQL batch.

 

Replication Procedures

Used to manage replication.

 

Security Procedures

Used to manage security.

 

SQL Mail Procedures

Used to perform e-mail operations from within SQL Server.

 

SQL Profiler Procedures

Used by SQL Profiler to monitor performance and activity.

 

SQL Server Agent Procedures

Used by SQL Server Agent to manage scheduled and event-driven activities.

 

System Procedures

Used for general maintenance of SQL Server.

 

Web Assistant Procedures

Used by the Web Assistant.

 

XML Procedures

Used for Extensible Markup Language (XML) text management.

 

General Extended Procedures

Provides an interface from SQL Server to external programs for various maintenance activities.

 

 

You can create your own system-stored procedures by following the guidelines outlined above. But, even though it is possible to modify an existing system sproc, it is better to name it with another name than to destroy the system version.

 

Dynamic Queries are created and executed within a stored procedure, and are built typically by passing in text parameters and creating a text SQL string. Then the string is executed using the form EXEC (@createdstring). Dynamic query plans are not stored in cache, and local variables created in the dynamic query are not available after the query is executed. To save the query plan, instead of the keyword EXEC, use sp_executesql. Also, with sp_executesql local variables can be used both as INPUT and as OUTPUT parameters.

 

Autoexec procedures, called autostart procedures can be made by invoking the system stored procedure

sp_procoption procedurename, startup, true

 

Extended Store Procedures

Extended stored procedures are auxiliary stored procedures created in a DLL using C++. They are prefixed with xp_, and stored in the Master database. When called from an application database, they must be fully referenced, using the Master..xp_procname form. Before you can invoke it, you must register the DLL with SQL Server using the syntax:

 

sp_addextendedproc [@functname=] ‘procedure’, [@dllname=] ‘dll’

 

Satish Kartan is a webmaster who is skilled in writing on data recovery topics as he has an in-depth knowledge on the very topic, data recovery. Kartan has been working with SQL Server for the past 20 years.

To read more you can visit Satish Kartan's blog where he has shared much more!

For more reading, please visit here: http://satishkartan.strikingly.com/


Share by: