Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 516
Kulis Avatar asked Oct 12 '16 17:10

Kulis


1 Answers

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

like image 136
user3210796 Avatar answered Oct 10 '22 15:10

user3210796