Kulis
Kulis

Reputation: 1010

Extended Events - Object cannot be added to the event session

When I am trying to run Extended Event:

CREATE EVENT SESSION [Loading] ON SERVER  
ADD EVENT sqlserver.sql_statement_completed(SET collect_statement=(1)) 
ADD TARGET package0.event_file(SET filename=N'C:\Users\user\Documents\test.xel',max_file_size=(10)) 
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=3 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF) 
GO 

on SQL Server 2016, I get:

The target, "5B2DA06D-898A-43C8-9309-39BBBE93EBBD.package0.event_file", encountered a configuration error during initialization. Object cannot be added to the event session. The operating system returned error 5: 'Access is denied. ' while creating the file 'C:\Users\user\Documents\test_0_131207679384970000.xel'. (Microsoft SQL Server, Error: 25602)

Where is the problem? I have enough permission for C:\Users\user\Documents.

Upvotes: 7

Views: 6480

Answers (2)

Unbreakable
Unbreakable

Reputation: 8122

You can use "C:\Temp" folder and it should work.

Upvotes: 1

user3210796
user3210796

Reputation: 176

You need to grant write permission to that folder to NTService\MSSQLServer, which is what the SQL Server service runs as.

Upvotes: 4

Related Questions