Merge results from several procedures into a single table

1

I have the following procedure where I pass the name of a column and it counts the records of that column.

exec psGraficoestatistica 'Email'

It returns a column with the name EMAIL and a single line with the number of occurrences.

I need to merge the result of several procedures like this into a single table. Is it possible?

exec psGraficoestatistica 'Email'
exec psGraficoestatistica 'Blogs'
exec psGraficoestatistica 'Google'
    
asked by anonymous 04.02.2015 / 14:55

2 answers

0

You can use the query below for this.

DECLARE @resultado as table(Email int, Blogs int, Google int)
INSERT INTO @resultado 
SELECT 
    exec psGraficoestatistica 'Email' as Email,
    exec psGraficoestatistica 'Blogs' as Blogs,
    exec psGraficoestatistica 'Google' as Google,

SELECT * FROM @resultado
    
04.02.2015 / 16:15
0

Use temporary or variable table:

CREATE TABLE #resultado (item VARCHAR(50), quantidade INT)
-- DECLARE @resultado TABLE (item VARCHAR(50), quantidade INT)
INSERT #resultado
-- INSERT @resultado
exec psGraficoestatistica 'Email'

INSERT #resultado
exec psGraficoestatistica 'Blogs'
    
04.02.2015 / 16:11