Database.StoredProcedures Database.StoredProcedures Database.StoredProcedures Property

Definition

Gets a collection of StoredProcedure objects. Each StoredProcedure object represents a stored procedure defined on the database.

public:
 property Microsoft::SqlServer::Management::Smo::StoredProcedureCollection ^ StoredProcedures { Microsoft::SqlServer::Management::Smo::StoredProcedureCollection ^ get(); };
[Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcObject(Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcContainerRelationship.ObjectContainer, Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcContainerCardinality.ZeroToAny, typeof(Microsoft.SqlServer.Management.Smo.StoredProcedure), Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcObjectFlags.Design)]
public Microsoft.SqlServer.Management.Smo.StoredProcedureCollection StoredProcedures { get; }
Public ReadOnly Property StoredProcedures As StoredProcedureCollection
Property Value

A StoredProcedureCollection object that represents all the stored procedures defined on the database.

Examples

VB

'Connect to the local, default instance of SQL Server.  
Dim srv As Server  
srv = New Server  

'Reference the AdventureWorks2012 database.  
Dim db As Database  
db = srv.Databases("AdventureWorks2012")  

'Display all the stored procedures in the database.  
Dim sp As StoredProcedure  
For Each sp In db.StoredProcedures  
   Console.WriteLine(sp.Name)  
Next  

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$db = New-Object Microsoft.SqlServer.Management.Smo.Database  
$db = $srv.Databases.Item("AdventureWorks2012")  

Foreach ($sp in $db.StoredProcedures)  
{  
   Write-Host $sp.Name  
}  

Remarks

Specific stored procedures can be referenced by using this collection by specifying the name of the stored procedure. To add a new stored procedure to the collection, call the stored procedure constructor StoredProcedure.

Applies to