Transact-SQL Stored Procedures
This section provides a comprehensive reference for Transact-SQL (T-SQL) stored procedures available in Azure SQL Database. Stored procedures are a set of T-SQL statements grouped together to perform a specific task. They offer benefits such as improved performance, reusability, and enhanced security.
System Stored Procedures
Azure SQL Database provides a rich set of system stored procedures for managing and querying database objects and server configurations. These procedures are typically prefixed with sp_.
sp_help- Returns information about a database object.sp_configure- Reports or changes current configuration options.sp_columns- Returns information about the columns of a specified table.sp_tables- Returns information about the tables in the database.sp_who2- Reports information about current users and processes.sp_lock- Reports information about the locks currently held by processes.
sp_help
Returns information about a database object, such as a table, view, or stored procedure.
Parameters:
| Parameter | Description |
|---|---|
@objname |
The name of the object for which to return information. |
sp_configure
Reports or changes current configuration options for the server. Use with caution.
Parameters:
| Parameter | Description |
|---|---|
@configname |
The name of the configuration option to change. |
@configvalue |
The new value for the configuration option. |
sp_columns
Returns information about the columns of a specified table.
Parameters:
| Parameter | Description |
|---|---|
@table_name |
The name of the table for which to return column information. |
sp_tables
Returns information about the tables and views in the database.
sp_who2
Reports information about current users and processes. Provides more detailed information than sp_who.
sp_lock
Reports information about the locks currently held by processes.
User-Defined Stored Procedures
You can create your own stored procedures to encapsulate custom logic for your Azure SQL Database. This promotes modularity and maintainability of your database code.