6

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.

Martin Smith
  • 438,706
  • 87
  • 741
  • 845
Kulis
  • 988
  • 3
  • 11
  • 25
  • 1
    Who is "I"? In order to create the file, the account that the SQL Server service is running under must have permission. By default, this is a custom-generated local account that only has permissions to access database files. – Jeroen Mostert Oct 13 '16 at 09:16
  • @JeroenMostert My user windows user. – Kulis Oct 13 '16 at 16:10

2 Answers2

2

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

user3210796
  • 156
  • 1
  • 10
0

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

Unbreakable
  • 7,776
  • 24
  • 90
  • 171