I think this may be inefficient, but I gave this a try:
Code:
declare @total int
declare @tot1 int
declare @tot2 int
CREATE TABLE #table1 (tot int)
INSERT INTO #table1 EXEC('SELECT COUNT(C.id)...')
CREATE TABLE #table2 (tot int)
INSERT INTO #table2 EXEC('SELECT COUNT(C.id)...')
SELECT @tot1 = tot FROM #table1
SELECT @tot2 = tot FROM #table2
SELECT @total = @tot1 + @tot2
RETURN @total
This didn't give any errors, but I'm having trouble getting it to produce results. In fact, my query appears to hang on it. Hope it's a start.
- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.