Thursday, June 2, 2016

xp_cmdshell in SQLServer 2014

Today I needed to create a job that moves files on the file system.

despite the recommendetions against xp_cmdshell, I use it because similar jobs do the same, so the SP has to exist on the server anyway. The problem was that running the move command in CMD line worked fine, while running the SQL code returned a "file access denied" exceptions.

Of course, the solution is to give access to the folders to the user that SQL Server runs under. Look at the services in task manager and add the user to the folder.