views:

209

answers:

3

Essentially I have a job which runs in BIDS and as as a stand lone package and while it runs under the SQL Server Agent it doesn't complete properly (no error messages though).

The job steps are:

1) Delete all rows from table;

2) Use For each loop to fill up table from Excel spreasheets;

3) Clean up table.

I've tried this MS page (steps 1 & 2), didn't see any need to start changing from Server side security.

Also SQLServerCentral.com for this page, no resolution.

How can I get error logging or a fix?

Note I've reposted this from Server Fault as it's one of those questions that's not pure admin or programming.

I have logged in as the proxy account I'm running this under, and the job runs stand alone but complains that the Excel tables are empty?

+1  A: 

Here's how I managed tracking "returned state" from an SSIS package called via a SQL Agent job. If we're lucky, some of this may apply to your system.

  • Job calls a stored procedure
  • Procedure builds a DTEXEC call (with a dozen or more parameters)
  • Procedure calls xp_cmdshell, with the call as a parameter (@Command)
  • SSIS package runs
  • "local" SSIS variable is initialized to 1
  • If an error is raised, SSIS "flow" passes to a step that sets that local variable to 0
  • In a final step, use Expressions to set SSIS property "ForceExecutionResult" to that local variable (1 = Success, 0 = Failure)
  • Full form of the SSIS call stores the returned value like so:

    EXECUTE @ReturnValue = master.dbo.xp_cmdshell @Command

...and then it gets messy, as you can get a host of values returned from SSIS . I logged actions and activity in a DB table while going through the SSIS steps and consult that to try to work things out (which is where @Description below comes from). Here's the relevant code and comments:

--  Evaluate the DTEXEC return code
SET @Message = case
                 when @ReturnValue = 1 and @Description <> 'SSIS Package' then 'SSIS Package execution was stopped or interrupted before it completed'
                 when @ReturnValue in (0,1)   then ''  --  Package success or failure is logged within the package
                 when @ReturnValue = 3        then 'DTEXEC exit code 3, package interrupted'
                 when @ReturnValue in (4,5,6) then 'DTEXEC exit code ' + cast(@Returnvalue as varchar(10)) + ', package could not be run'
                 else 'DTEXEC exit code ' + isnull(cast(@Returnvalue as varchar(10)), '<NULL>') + ' is an unknown and unanticipated value'
               end
--  Oddball case: if cmd.exe process is killed, return value is 1, but process will continue anyway
--  and could finish 100% succesfully... and @ReturnValue will equal 1.  If you can figure out how,
--  write a check for this in here.

That last references the "what if, while SSIS is running, some admin joker kills the CMD session (from, say, taskmanager) because the process is running too long" situation. We've never had it happen--that I know of--but they were uber-paranoid when I was writing this so I had to look into it...

Philip Kelley
Thanks for a very fulsome explanation, I may well return to this code in future.
alimack
A: 

Why not use logging built into SSIS? We send our logs toa database table and then parse them out to another table in amore user friendly format and can see every step of everypackage that was run. And every error.

HLGEM
It wan't logging any error messages!See my solution.
alimack
You have to set up logging inthe package. Did you do that? ANd it still wasn't logging?
HLGEM
A: 

I did fix this eventually, thanks for the suggestions.

Basically I logged into Windows with the proxy user account I was running and started to see errors like: "The For each file enumerator is empty"

I copied the project files across and started testing, it turned out that I'd still left a file path (N:/) in the properties of the For Each loop box, although I'd changed the connection properties. Easier once you've got error conditions to work with. I also had to recreate the variable mapping.

No wonder people just recreate the whole package.

Now fixed and working!

alimack