SQL Agent Export Job is failing with Access is Denied error - sql-server-2014

I have created an export task to export a view into an excel file onto a folder location. The task runs fine and exports to excel in the correct place. I ahve now saved this task in SSIS.
I am now trying to create a SQL agent scheduled job to run the task daily. I have SQLServerAgent and MSSQLServer access to the folder location however it keeps failing with the error:
Executed as user: NT Service\SQLSERVERAGENT. The process could not be created for step 1 of job 0x3FF5419F86864B47A653A928777E56DE (reason: Access is denied). The step failed.,00:00:00,0,0,,,,0
I have looked this up online and there were suggestions to try ticking the use 32bit runtime checkbox which i have also tried and still keep getting the same error.
Does anyone know what i can do to get the SQL agent job to run successfully?

I found the cause. The reason was I gave SQLServerAGent read/write access to the folder but it needed modify permission. Once i gave it modify it worked fine

Related

SSIS Package Error "Cannot update. Database or object is read-only." for Excel Destination

When I execute a package in Visual Studio it works fine. However, when executing that package in SQL I run into this error "Cannot update. Database or object is read-only." and the Subcomponent name for this error message, is Excel Destination.
I tried adding "IMEX=0;Readonly=False", to the connection string of Excel Connection Manager but didn't help
I saw this https://stackoverflow.com/a/42654325/12021687 and I know my database is read-only (which I can't change) but I don't believe it relevant to me as the Subcomponent name of the error message is Excel Destination.
Can someone guide me on what may be causing this issue?
Permission Issue. Package may not be running under the user you are expecting.
Try changing the security permissions of the file/folder to full control for NT SERVICE\SQLSERVERAGENT.
Rerun the package. If this works check who the file was last saved by and give this user the required permissions.
p.s. Very Frustrating issue for myself too!
Edit
Also before I found the above as soloution:
I set DelayValidation = True everywhere in the Project.
Added ;READONLY=0 on the connection string

SSIS EXECUTE TASK not working as expected through sqlserver agent

I have created a SSIS Execute Task package to export CSV and write into d:/ drive
It works when i execute from SSIS.However when i run from SQLServer agent, the job shows sucess but the export file is not available in the location
Can anyone please advise if anything i am missing.
Thank you
I think that the issue is that the SQL agent doesn't have access to the file system location. Make sure that SQL service account has needed permissions:
Configure File System Permissions for Database Engine Access

Scheduled MS Access macro to run query and export to CSV

I'm trying to get a windows Scheduled Task to open up MS Access DB (.mdb) which has an AutoExec macro that runs some queries and then exports it to a .csv replacing the .csv file that is already there.
From the command prompt I can run:
"C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE" "/Path to my Access DB"
and everything works perfectly. Access opens up, runs the query, and replaces the .csv with new data from the query.
When I try to do this with a Scheduled Task access just deletes the .csv file without ever replacing it and returns the error "the operator or administrator has refused the request".
Any ideas? I was looking for a quick way to get the data but I feel like I might be better off just writing some python to connect to Access.
I was able to return to this problem this week and finally found the solution.
The problem came down to the scheduled task. It was a local machine permissions issue and running the task with the correct domain that solved it.
First to fix the local machine permission I had to make sure that the user running the task had "Log on as a batch job" permissions.
Found at Control Panel -> Admin Tools -> Local Security Policy\Local Policies\User Rights Assignments -> "Log on as a batch job"
Second, because I was on a domain the schedule task had to be explicitly created by the domain user. I had to manually find the user on the domain during the creation of the task and remove the user that was auto populated by the task scheduled creation wizard.

SSIS Flat File Folder Permission

I am using SSIS to export a CSV file to a folder location that needs credentials for access so we can SFTP it to a client.
What permissions do I need to set? I don't see any way to set username and passwords in the Flat File Destination.
Currently I get a error when trying to export the file:
Warning: 0x80070005 at Data Flow Task, Flat File Destination [2]: Access is denied.
Error: 0xC020200E at Data Flow Task, Flat File Destination [2]: Cannot open the datafile "\\SERVER\FOLDER\Dropoff\ELIGIBILITY.CSV".
Error: 0xC004701A at Data Flow Task, SSIS.Pipeline: Flat File Destination failed the pre-execute phase and returned error code 0xC020200E.
I thought I had generated a file in a folder with permissions before but I don't do a lot with SSIS and don't remember what I did.
SSIS simply executes as the user running the package. So if you are running from your dev machine it is your Windows credentials which will need access.
If you are running from a SQL Agent Job then the SQL Agent Service Account user will need permissions (or use a proxy)
Just in case this helps anyone, I was also getting this error and could not figure out why it would execute when running the package directly (in my case through VS) but not from SQL Server Agent. All the permissions seemed correct. I finally tried deleting the existing file (I had it set up to overwrite the data in the existing file in that directory) and re-ran the job and it worked. After that, it has worked fine. So there seems to have been some permission issue (maybe?) or conflict with the file I originally created through VS and the file created through the SQL Server Agent job.

Flat File Source Failing When Deployed and Executed

I am trying to create a simple SSIS package that can be deployed to a VM on another domain (same computer) that has SSIS on it. The package that I have created will transfer data if I simply run the data flow from SSDT on the source computer, but when I try to deploy and execute it, it appears to have 2 errors. The first being that it cannot open the datafile "C:\SSIS\Product Data.txt". The second being that the Flat Files Source 1 failed the pre-execute phase. I think that the second error is caused from the first. Does anyone know how to create a package that can transfer data to another computer without the flat file source?
Thanks in advance!
C:\SSIS.... will refer to the local C drive of the computer that is executing the package. So if you have it on the VM it would be at the \VM\C$. Typically it means 1 of 2 things.
1) The file path is not correct and you are not referencing where the file actually is.
2) the user you are executing the package as does not have permission to that file.
So where is the file is it on the C drive of the machine you are executing the SSIS package on? The answer to that wasn't clear in your question.
Second how is the file being executed? manual execution such as DTS_Exec? SQL Agent? T-SQL? If manual then the user logged in executing the task must have permission, if SQL Agent then the sql agent service account and possible the sql server service account have to have permission to the file, and T-sql sql server service account needs to have permission.
When it is local file path then a local user or domain user will work for the service accounts. If network path then the local user used for service account won't work and you will need to setup a way to run as a different credential.