If I do an extended event session like this in SQL Server 2008 R2:
CREATE EVENT SESSION [Query tracing] ON SERVER
ADD EVENT sqlserver.rpc_completed
(
ACTION(sqlserver.sql_text)
WHERE sqlsever.database_name = 'master'
I get an error:
Msg 25706, Level 16, State 8, Line 8
The event attribute or predicate source, "sqlsever.database_name", could not be found.
The same occurs for WHERE sqlsever.database_id = DB_ID('master')
Is there any way to filter by database?
Best Answer
Two things that are the problem.
There is no
database_name
action in SQL Server 2008 R2 (it was introduced in SQL Server 2012):The output from that is:
But there is
sqlserver.database_id
. The second problem is that your attempt withdatabase_id
didn't work because you have a typo (you have "sqlsever", missing an "r").