Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jkrassman
Starting Member
1 Post |
Posted - 2006-12-16 : 20:11:16
|
Hello sql gurus!I have been searching this forum and I have seen a lot of questions that are similiar to this one, but I am hoping that someone could help me out with this. -I am sorry if this has been posted before -but I cant get this to work. Even if I have found a lot of information about this issue.I have a table in a MSSQL 2005 and I want a query or a stored procedure to deliver the following information in a temp table or just a recordset. The table is where I handle all replies in a forum so there is a ID for the record and the table also has a ReplyID that could refer to a ID in the same table. It could look something like this:ID ReplyID1 NULL2 13 14 25 4So the basic is just a recursive sql statment. The thing is that I want the recordset to be sorted by the ID -and the following replies. But I allso want the recordset to deliver a integer that tells me how far I should indent the output. So the perfect result in a temp table or a recordset would be like this:ID ReplyID Indent1 NULL 02 1 13 1 14 2 25 4 3finnaly, i want all threads to be sorted by the referer or the recordset that has null as an value. Is this possible? My table that I am refering is to - is namned by tblReplies and the columns is ID and replyid.Best regards, Joakim Krassman |
|
|
|
|