. Net flip Control
// Retrieve the total number of records
Create procedure DBO. yourcompany_ywkj_pagegetcount
@ Tabname nvarchar (50 ),
@ Colname nvarchar (50 ),
@ ID int
As
Exec ('select count (*) as num from '+ @ tabname + 'where' + @ colname +' = '+ @ ID)
Go
// Page flip
Create procedure yourcompany_ywkj_meaagereplyfortopicid
@ Topicid int,
@ Indent int,
@ Startindex int,
@ Endindex int
As
If (@ indent = 1)
Begin
Set nocount on
Declare @ indextable table (ID int identity (1, 1), nid int)
Set rowcount @ endindex
Insert into @ indextable (NID) Select messageid from message where topicid = @ topicid order by messageid
Select M. messageid, M. topicid, U. username, M. messagecontent, M. messagecreatetime
From message m, users U, @ indextable t where M. topicid = @ topicid and M. messageuserid = U. userid
And M. messageid = T. Nid
And T. ID between @ startindex and @ endindex order by T. ID
Set nocount off
End
Else -- Obtain the msgid of this topic
Begin
Select messageid
From message
Where topicid = @ topicid and indent = 0
End
Go