I want to use rowset variable as scaler variable.
@cnt = Select count(*) from @tab1;
If (@cnt > 0) then
@cnt1= select * from @tab2;
End;
Is it possible?
======================================
I want to block the complex u-sql code based on some condition, lets say based on some control table. In my original code, I wrote 10-15 u-sql statements and I want to bound them within the If statement. I don't want to do cross join because it again start trying to join the table. If I use cross join, there is no significant save in execution time. Use of IF
statement is, If the condition does not met, complete piece of code should not execute. Is it possible?
(Adding explanation) CROSS JOIN returns a cartesian product of all rows from @tab2 and the single row generated by the COUNT query. There WHERE condition then ensures the result of the query is all rows from @tab2 if COUNT(*)>0, no rows otherwise.