Michael_DePew_8870

how to determine if a SQL variable object will have results

Discussion created by Michael_DePew_8870 on Feb 6, 2017
Latest reply on Feb 7, 2017 by Wolfgang_Brueckler_1288

My goal is to use a SQL variable object in a notification, but I only want the notification to run if the SQL variable returns rows.  So if there are 0 rows, I don't want the notification to send at all.

I envision a workflow with a separate task that checks the SQL variable for the presence of results, then the notification being dependent on that as ANY_OK or else skipping it.  However, I'm also trying to just avoid running the query itself twice.

Things I've thought of for the check task:

1)  Use GET_VAR as a check which will just grab 1 row

2) Run a separate job that just does the same query but with a TOP 1 clause to check if there will be at least 1 row

3) Is there a built in function that will return a row count of a SQL variable?

What is the most efficient way to do this?

Thank you in advance for any advice.

Outcomes