Trigger.Create Method

Creates a trigger on the instance of Microsoft SQL Server as defined by the Trigger object.

命名空間: Microsoft.SqlServer.Management.Smo
組件: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)

語法

'宣告
Public Sub Create
public void Create ()
public:
virtual void Create () sealed
public final void Create ()
public final function Create ()

備註

只有 Microsoft .NET Framework 2.0 版支援此命名空間、類別或成員。

範例

'Connect to the local, default instance of SQL Server.
Dim mysrv As Server
mysrv = New Server
'Reference the AdventureWorks database.
Dim mydb As Database
mydb = mysrv.Databases("AdventureWorks")
'Declare a Table object variable and reference the Customer table.
Dim mytab As Table
mytab = mydb.Tables("Customer", "Sales")
'Define a Trigger object variable by supplying the parent table, schema ,and name in the constructor.
Dim tr As Trigger
tr = New Trigger(mytab, "Sales")
'Set TextMode property to False, then set other properties to define the trigger.
tr.TextMode = False
tr.Insert = True
tr.Update = True
tr.InsertOrder = Agent.ActivationOrder.First
Dim stmt As String
stmt = " RAISERROR('Notify Customer Relations',16,10) "
tr.TextBody = stmt
tr.ImplementationType = ImplementationType.TransactSql
'Create the trigger on the instance of SQL Server.
tr.Create()
'Remove the trigger.
tr.Drop()

執行緒安全性

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

平台

開發平台

如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。

目標平台

如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。

請參閱

參考

Trigger Class
Trigger Members
Microsoft.SqlServer.Management.Smo Namespace

其他資源

How to: Create, Alter, and Remove a Trigger in Visual Basic .NET
Creating, Altering, and Removing Triggers
DML 觸發程序
CREATE TRIGGER (Transact-SQL)