I am trying to create a table variable that will store the output of one query, using the 4 tables
SELECT COUNT(*)
FROM [dbo].[ADF_Path]
WHERE PathActive = 'y'
UNION
SELECT COUNT(*)
FROM [dbo].[ADF_Course]
WHERE CourseActive = 'y'
UNION
SELECT COUNT(*)
FROM [dbo].[ADF_Section]
WHERE SectionActive = 'y'
UNION
DECLARE @ACtiveGroup TABLE
(
SELECT COUNT(*) FROM [dbo].[ADF_Path]
WHERE PathActive = 'y'
UNION
SELECT COUNT(*) FROM [dbo].[ADF_Course]
WHERE CourseActive = 'y'
UNION
SELECT COUNT(*) FROM [dbo].[ADF_Section]
WHERE SectionActive = 'y'
UNION
SELECT COUNT (*) FROM [dbo].[ADF_Event]
WHERE EventActive = 'y'
)
SELECT FROM @ACtiveGroup
ADF_Path had 1 record ,Course has 7, Section has 110 and Event has 636 when I run the the query using the where clause. I