SELECT TOP 1000 [ID] ,[ParentID] ,[Name] ,[Content] ,HasChildren = ISNULL((SELECT 1 WHERE EXISTS(SELECT TOP 1 1 FROM t_Tree WHERE ParentID = A.ID)),0) FROM [Test].[dbo].[t_Tree] A