SQL Server Count records from parent category and all subcategories
问题 Currently I have a stored procedure where I create a table and query the table to get my desired result, the result being an infinitely tiered child/parent table that allows me to display the data on my ASP Classic based webpage. This procedure is: SET NOCOUNT ON; DECLARE @Categories TABLE( CatID INT NOT NULL, CatName VARCHAR(200) NOT NULL, ParentID INT ) INSERT INTO @Categories SELECT CatID, CatName, ParentID = NULL FROM Categories WHERE CatName NOT IN ( SELECT CatName FROM Categories c