1

Is there a way to process creating of a SEQUENCE object in a SQL CLR DDL trigger as it is done with creating a table?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • So you want to create a CLR DDL trigger and within it create a sequence? I'm sure it can be done, but why? That seems very convoluted. – Ben Thul May 29 '15 at 17:44
  • No, a need a DDL trigger to execute on a sequence creation so that I can identify the reason if was triggered for (for instance, distinguish it from triggering on table creation) and perform some action after it. – Dzmitry Sauchanka May 30 '15 at 09:55
  • Ah... that makes more sense. It looks to me like sequences aren't accounted for by looking at the enumeration documented here (https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.server.triggeraction.aspx). As an experiment, I'd suggest writing your trigger to emit the string value of a `TriggerAction` object created in the context of your trigger. Alternatively, the `EventData` may hold some interesting information. – Ben Thul May 30 '15 at 13:03
  • Indeed, sequence creation fires a DDL trigger and `TriggerAction` property is equal to `303` in this case though there is no such enumeration element in `TriggerAction` enum. Comparing `TriggerAction` property to `(TriggerAction)303` returns `true` so there is quite an easy but not documented way to distinguish sequence creation from other DDL actions in SQL CLR DDL trigger. – Dzmitry Sauchanka Jun 09 '15 at 11:17

0 Answers0