|
SQLDMO - Adding a New Trigger
|
|
Let's say you want to add a new trigger to an existing table. Although it is
possible to directly use SQL Server for this, or even SQL-NS (see
my contribution on the same at MSDN India), another solution is to use SQL-DMO to do this
operation. SQL-DMO provides an object view of all SQL Server objects can be used in any COM-enabled
environment. In this article, we will see how to use VB.NET and SQL-DMO to add a new trigger to an
existing table.
The steps in getting the list of indexes using SQL-DMO are:
Here is an example:
The above program will create an insert trigger on the authors table. Note that each change that we make to an object in SQL Server is automic in itself. If we want to batch a set of changes, we need to use the BeginAlter and the DoAlter methods on the appropriate object. |
| Home |