问题
I created an Extended Event Session using a script with a Where clause in order to filter commands which refers to a table whose name is MySchema.MyTable:
WHERE ([sqlserver].[like_i_sql_unicode_string]([sqlserver].[sql_text],N'%MySchema.MyTbl%'))
The problem is that the table can appear in one of the 4 following ways:
MySchema.MyTable
[MySchema].MyTable
MySchema.[MyTable]
[MySchema].[MyTable]
I can create a long Where clause with al those options and the "Or" operator between them (a to find a good solution to the ambiguity of the characters ],[), but it is not very elegant. I wish I could use Replace operator in order to remove those characters (],[) but I don't know how.. Any suggestions?
回答1:
After some investigation I think a good solution would be to filter by the object_id instead of by manipulating the SQL string in order to find the object name
来源:https://stackoverflow.com/questions/27835678/how-to-filter-a-table-name-in-extended-events