Friday, March 9, 2012

Execute sql task

I execute a sql task to get full resultset. How do i stop processing (With Package success) the package (With Package success) if the resultset returned is empty? Their does not seem to be any swith or expression to stop processing if i dont get any results.

You can use a script task to see if the recordset has any rows in it, and set a variable with the result.

|||Do i get any value using the sqltask over using script? If i have to revert to script to check for results would it not be better to do the whole task in script? It seems this is the case with alot of the tasks, Microsoft do say you will write less script than you did in DTS but it does seem you cant achieve an entire Task without doing a portion in script. Just my thoughts will be intrested to see what other people think.

|||

I would still use the Execute SQL to get the resultset. It makes it more obvious what you are doing.

Are you iterating through the resultset to process it? If you are using the ForEach Container, it should skip the contents of the container if there are no rows.

|||I am using the foreach container, problem is their is a task after the foreach container i donot want to run if no results returned so although it skips the foreach it runs the next task after it.

|||

Another thought - you could use two Exec SQL tasks. One to get the record count, one to get the recordset. That would avoid the use of script altogether.

No comments:

Post a Comment