SQL SERVER 2008 TRIGGER ON CREATE TABLE

后端 未结 2 558
感情败类
感情败类 2021-01-23 00:12

Is there a way to run some function like a trigger when a table is created in the database in SQL SERVER 2008?

2条回答
  •  青春惊慌失措
    2021-01-23 00:39

    Yes, it's called a DDL trigger. The documentation for CREATE TRIGGER has a sample for DROP_SYNONYM (a very questionable choice for an example) but you'll want the CREATE_TABLE event instead. A better starting point in understanding how they work is probably here:

    http://msdn.microsoft.com/en-us/library/ms190989.aspx

    If you have more specific details, e.g. what exactly do you want to pass to this function (I assume you mean procedure), or what does the procedure do, we can provide more useful and specific help.

提交回复
热议问题