System Stored Procedures

System stored procedures are built-in stored procedures that are installed with SQL Server. They perform a variety of system-level tasks, such as managing database objects, monitoring server performance, and performing backups and restores. You can execute system stored procedures by prefixing their names with sp_. Most system stored procedures are stored in the master database.

Overview

System stored procedures provide a powerful way to interact with and manage your SQL Server instance. They are essential for administrators and developers alike. Here are some common categories:

Common System Stored Procedures

Database Management Procedures

These procedures help in managing the structure and contents of your databases.

Security Management Procedures

Control access and permissions within your SQL Server instance.

Performance Monitoring Procedures

Gain insights into your SQL Server's performance and resource utilization.

Example: Checking Current Processes

To see all active processes and their status, you can execute:

EXEC sp_who;

Backup and Restore Procedures

Essential for data protection and disaster recovery.

Tip

While BACKUP DATABASE and RESTORE DATABASE are T-SQL statements, they are the primary tools for data protection. You can use system stored procedures like sp_addumpdevice to configure where these backups are stored.

Configuration Procedures

Modify and view server-level configuration options.

Note

When using sp_configure, you often need to run RECONFIGURE WITH OVERRIDE to apply the changes. Be cautious when changing server configuration settings, as they can significantly impact performance and stability.

Important Considerations

Warning

Avoid executing system stored procedures directly on production systems unless you are fully aware of their impact. Always test changes in a non-production environment first.