Unite results of various procedures in a single table

Asked

Viewed 851 times

1

I have the following process 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 amount of occurrences.

I need to merge the result of various procedures like this into a single table. It is possible?

exec psGraficoestatistica 'Email'
exec psGraficoestatistica 'Blogs'
exec psGraficoestatistica 'Google'

2 answers

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'

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.