Microsoft SSIS Package running successfully manually from Visual Studio and SSMS Integration Services Catalog, but not via SQL Server Agent - tsql

I have a complex SSIS package, which detects the file extension from a folder, and loads the file into a SQL Server table. I have a For Each Loop Container to load a number of files in this manner, from this folder location and load each file into a SQL Server table.
After the loading of each file into the SQL Server table, the SSIS has a File System Task in the Control Flow; this File System Task first creates an archive folder and then moves each file into this archive folder.
I am using Environment Variables in the SSMS Integration Services Catalog, to map to the parameters in the SSIS package/project.
The entire process is successful when I run the SSIS package in the SSMS Integration Services Catalog manually, but when I try to run via a SQL Server Agent, the data loading and the (File System Task's) folder creation are successful, but not the File System Task's file moving process. (The Agent is Run as SQL Server Agent Service Account.)
I get the following error when I see the execution report in the Integration Services Catalog in the SSMS:
File System Task - Move Files:Error: An error occurred with the following error message: "Access to the path is denied.
While the SQL Server Agent is able to create a folder using a File System Task successfully, it is not able to
move the file into this new folder location.
Inside the SQL Server Agent History, I see this in the job step:
Execute as user: NT Service\SQLSERVERAGENT. Microsoft(R) SQL Server Execute Package Utility Version 14.0.2002. 14 for 64-bit.
... Package execution on IS Server failed. Execution ID: 30449, Execution Status : 4.
I am not good with this permission issue in SQL Server Agent. I read about some proxy setting etc. but am not able to comprehend.
Is there a step-by-step solution you can provide me to fix this issue ?

The SQL Agent job executes the package using the SQL Agent service account. When you run the package manually, the package executes using the credentials you used to sign in. Most likely the SQL Agent service account does not have enough access to the directory, especially if it has just been created. Make sure the service account has "Full Control" of the directory the package is referencing. To test whether it is an access issue, log on to the server using the service account credentials and manually run the package from the SSIS catalog. If it fails for the same reason, you know you need to look at file system access for the service account.

Related

Instant logging and file generation in Db2

I am currently using Community version on linux server, have configured db2audit process
Which generated audit files at respective location. Then user have to manually execute db2audit archive command to achieved logs file and have to execute thedb2 extract command to extract the archived files into flat ascIII files and then we have to load the files into respective tables.
There only we can analyze the logs by query the tables. In this whole process lots of manual intervention is required.
Question:-Do we have any config settings or utility
with the help of which we can generate logs files which include SQL statement event, host, session id,Timestamp and all instantly and automatically.
need to set instant level logging mechanism to generate flat files for logs of any SQL execution happened or any event triggered in database level in DB2 on linux server

TFS Build "PowerShell on Target Machines" Step Fails: How to debug?

I'm trying to automate the deployment of the solution my team is working on through TFS Build server. One of the steps which executes a PowerShell script on the target machine fails with the following error:
Microsoft ODBC Driver 11 for SQL Server : Login failed for user 'sa'..
The PowerShell script I'm trying to execute does in fact connect to multiple databases using the sa credentials. When I try to execute the same script passing it the exact same arguments by hand (i.e: executing the script from the target machine VM itself) it works like a charm. But when it is being executed as part of the build steps it fails with the aforementioned error.
Is there a way to further debug the issue? It would be great if there is a way to output trace statements from the script so I could have some insight on what is actually going on.
Usually all the related error should reflect in TFS build log. To narrow your issue you can try to connect to the TFS build agent with the credentials used for the build service and manually run the ps script.
If you execute the ps script with your own account, which will not help to the issue. Usually this kind of problems is related to permissions. Your build service account are lack of related permission. Try to add it to Administrator or SQL Administrator group and execute the build again.

Unable to configure TFS backup using Backup wizard

When trying to configure the TFS 2010 backup using the TFS Power Tools I kept running into teh following error message:
Account TFS\tfsadmin failed to create backups using path \\tfs-xxxxxxx.local\TFSBackups
The strange thin is that TFS\TFSAdmin has full permissions on both share and file system and that the share path doesn't contain any spaces (thanks for MSDN forums for pointing that out).
I tried backing up through the SQL Server Management Studio, and sure, there the backups fail too.
It turns out that while the backup job is started using the account specified in the Create Backup Wizard of the TFS Power Tools, SQL Server will try to write the files to the share using its own service account.
So in addition to whomever needs access to the share, you need to add the service account running SQL Server to that share as well. In this case it was running under NETWORK SERVICE, so adding MACHINENAME$ to the share's list of permitted users did wonders.

running an exe file from a sql job

i'm trying to run an exe from a sql job.
the db is on the server, as well as the exe file.
the exe is supposed to write stuff on a log.
even though the sql job is successful, i see no change on the log file.
i've checked the exe locally, and it does work.
The job runs on type cmdexec, and the command is :
\\ustlvint02\c\FixProjectsWhichFailedSync\FixProjectsWhichFailedSync.exe
ustlvint02 - the server's name.
the path is valid, since i tested it by running it from my computer (and there, the log isn't created as well).
i'll appreciate any help you can offer.
Hadas
The account that SQL Server Agent runs on needs to have permissions to 1.) un the exe in that location and 2.) write to the log file location.
Find out account is used by SQL Agent, then verify that this user has the proper execute and write permissions.
Look for the log file in %WINDIR%\System32 (for 32-bit version of SQL Server) or in %WINDIR%\SysWOW64 (for 64-bit version of SQL Server), where %WINDIR% is a path to the folder where Windows is installed (typically, C:\Windows). This destination does not depend on the system account specified for the SQL Agent job. All files which your executable needs to write to or read from must be either specified within an absolute path or be specified within a relative path and thus be present in the aforementioned system folder.

Transfer SQL job to another machine

How can I transfer my SQL Agent job (maintenance plan) from my server to another server?
I use SQL Server 2008 R2. My job runs a T-SQL script.
The following article explains how to to do it: Migrating a Maintenance Plan from One SQL Server to Another.
Note that they're using SQL Server 2000, but it should work for SQL Server 2008 R2 as well.
I solve this problem in this way:
I use SSIS to transfer SQL Agent job (maintenance plan) from my server to another server.
this is the way that i use:
Open SSIS and go to Stored package --> MSDB --> maintenance plan and right click on your job and choose export
choose file system for location
choose the path for your package
copy your file in new server
connect to another machines SSIS
now choose import package on MSDB
go to maintenance plan and save your job or run Creat script