SqlProcedureAttribute Class

Definition

Used to mark a method definition in an assembly as a stored procedure. The properties on the attribute reflect the physical characteristics used when the type is registered with SQL Server. This class cannot be inherited.

C#
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)]
[System.Serializable]
public sealed class SqlProcedureAttribute : Attribute
Inheritance
SqlProcedureAttribute
Attributes

Examples

The following example shows a method declaration in an assembly that has been attributed as a stored procedure. The SqlProcedureAttribute property has been set to the name of the stored procedure.

C#
[Microsoft.SqlServer.Server.SqlProcedure(Name = "StoredProcSendMessage")]
public static void StoredProcSendMessage()
{
    // Send a message string back to the client.
    SqlContext.Pipe.Send("Hello World!");
}

Remarks

SqlProcedureAttribute is used only by Microsoft Visual Studio to automatically register the specified method as a stored procedure. It is not used by SQL Server.

See "CLR Stored Procedures" in SQL Server 2005 Books Online for more information on CLR stored procedures and examples.

Constructors

SqlProcedureAttribute()

An attribute on a method definition in an assembly, used to indicate that the given method should be registered as a stored procedure in SQL Server.

Properties

Name

The name of the stored procedure.

Applies to

Proizvod Verzije
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1