SqlProcedureAttribute 類別

定義

用於將組件中的方法定義標記為預存程序 (Stored Procedure)。 該屬性 (Attribute) 上的屬性 (Property) 反映使用 SQL Server 註冊型別時使用的實體特性。 此類別無法獲得繼承。

public ref class SqlProcedureAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)]
[System.Serializable]
public sealed class SqlProcedureAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)>]
[<System.Serializable>]
type SqlProcedureAttribute = class
    inherit Attribute
Public NotInheritable Class SqlProcedureAttribute
Inherits Attribute
繼承
SqlProcedureAttribute
屬性

範例

下列範例顯示已屬性為預存程式之元件中的方法宣告。 屬性 SqlProcedureAttribute 已設定為預存程式的名稱。

[Microsoft.SqlServer.Server.SqlProcedure(Name = "StoredProcSendMessage")]
public static void StoredProcSendMessage()
{
    // Send a message string back to the client.
    SqlContext.Pipe.Send("Hello World!");
}
<Microsoft.SqlServer.Server.SqlProcedure(Name:="StoredProcSendMessage")> _
Public Shared Sub StoredProcSendMessage()

    ' Send a message string back to the client.
    SqlContext.Pipe.Send("Hello world!")

End Sub

備註

SqlProcedureAttribute 僅由 Microsoft Visual Studio 用來將指定的方法自動註冊為預存程式。 SQL Server不會使用它。

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

建構函式

SqlProcedureAttribute()

組件中方法定義上的屬性,用於指出指定之方法應該在 SQL Server 中註冊為預存程序。

屬性

Name

預存程序的名稱。

適用於