tags:

views:

29

answers:

1

Does anyone know what the SQL Server trace Event ID or Event Name for Create Index is or where I could find the answer? I suspect it is 'Alter User Table' but I need to be certain.

+1  A: 

In Profiler, what you want is in Objects -> Object:Created. This will show any DDL events. Then, in the column filters set the Like filter on the TextData column to Create Index%.

For a trace, you want the Object:Created event (eventId = 46). So something like:

sp_trace_setevent [your trace id] 
          , @eventid = 46 -- Object:Created
          , @columnid = 1 -- TextData column
          , [ @on = ] on

sp_trace_setfilter [your trace id]
          , @columnid = 1 -- TextData column
          , @logical_operator = 0 -- AND
          , @comparison_operator = 6 -- LIKE
          , @value = 'Create Index%'
Thomas
yep, text filter is the only way AFAIK. The "Object:Created" event even mentions CREATE INDEX http://msdn.microsoft.com/en-us/library/ms186265.aspx I would use Create%Index% though because of NONCLUSTERED and UNIQUE usage, or add these as filters
gbn
@gbn - RE: Filter. Excellent point on Create%Index%.
Thomas