I\'m trying to create a forum setup where you can comment on specific posts and have the replies show immediately below the parent in date order. There will only be one sub-lev
For a single level depth, you don't need to use recursion - try:
SELECT ID, ParentID, Datestamp
FROM ForumMessages
order by coalesce(ParentID,ID), Datestamp
Very easy way without CTE (ISNULL is the function in MSSQL but you don't give the RDBMS):
SELECT ID, ParentID, Datestamp
FROM ForumMessages
ORDER BY ISNULL(ParentID,ID), DateStamp
Fiddle