0

I am developing a SSIS package with Package deployment model on SQL Server 2016 environment. I have a File Move functionality which is running fine from Visual studio and also when it is run manually from command prompt using below command

"C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\DTExec.exe" /F "D:\project\Package1.dtsx"

When the same is schedules from Task scheduler Files are not moved from one folder to another on the same system.

initially I used File System Task which also behaved as explained above. later I replaced it using Script task and wrote below line of code. Still it is not working.

        try
        {
            System.IO.File.Move(Convert.ToString(Dts.Variables["User::FileName"].Value), Convert.ToString(Dts.Variables["User::ProcessFolder"].Value));
        }
        catch (Exception)
        {


        }
captainsac
  • 2,484
  • 3
  • 27
  • 48
  • 2
    You actually have an empty catch block? – Zer0 Apr 05 '20 at 18:22
  • Let it come to you. In the event log or whatever. – Oguz Ozgul Apr 05 '20 at 18:25
  • File move is working fine when run from Visual Studio or Command Prompt – captainsac Apr 05 '20 at 18:30
  • But when run from task scheduler something goes wrong and you just don't care what it was. Log the exception please. Log, along with the exception, the values of both `Dts.Variables["User::FileName"].Value` and `Dts.Variables["User::ProcessFolder"].Value` – Oguz Ozgul Apr 05 '20 at 18:43

1 Answers1

0

I'm having the same problem. I'd love to log the exception. In my case, there is no exception. The task runs to successful completion (at least that's what the output says). But, no file is moved, no log files created. Everything looks normal in the logs and reports I can see.

I found two things, not sure which one fixed it. Make sure the script task has the same platform target (32 vs 64 bit) as the server. Per: SSIS is executing successfully, but it doesn't seem to be running the script task portion

1) Edit Script

2) Right click the c# project name that looks like a GUID and choose properties

3) Select the Build menu on the left side of the properties page

4) Set the Platform target = x86

I also made sure the target in the Data Tools matches the server version. In developer setup:

1) Right click the project and select Properties

2) Under Configuration Properties select General

3) Set the TargetServerVersion to your target SQL server.