sql - Procedure Paging for GridView -
i in loop set info @tbl2 table @tbl table. unfortunately don`t know have set insert (insert @tbl2 values(@id,?,?)) mean sec , 3rd parameter.
mssql 2008 r2
for example(table @tbl):
specid | sp
3 | '5/1/2008 8:30:52 am'
8 | '5/1/2008 8:30:52 am'
9 | '5/1/2008 8:30:52 am'
and if @count = 3 take info (9 | '5/1/2008 8:30:52 am')
declare @tbl table ( specid bigint, sp datetime ) declare @tbl2 table ( id int, specid bigint, sp datetime ) declare @id int declare @count int declare @firstnumber int declare @secondnumber int set @firstnumber = @pagesize * 10 set @secondnumber = @firstnumber - 10 while (@count <= @totalrowsnumber) begin if @count > @secondnumber , @count <= @firstnumber begin set @id +=1 insert @tbl2 values(@id,?,?) end set @count = (@count + 1) end
you there... @ one:
declare @tbl table ( id int identity(1, 1), specid bigint, sp datetime ) declare @tbl2 table ( id int, specid bigint, sp datetime ) declare @id int declare @count int declare @firstnumber int declare @secondnumber int declare @pagesize int declare @totalrowsnumber int set @firstnumber = @pagesize * 10 set @secondnumber = @firstnumber - 10 -- populate tbl insert @tbl select value1, value2 original_table set @totalrowsnumber = @@rowcount set @count = 1 while (@count <= @totalrowsnumber) begin select @value1 = value1 , @value2 = value2 @tbl id = @count if @count > @secondnumber , @count <= @firstnumber begin set @id +=1 insert @tbl2 values(@id,@value1,@value2) end set @count = (@count + 1) end
what did. @tbl needs column, called id. identity column utilize referencing in later stadium. next populate @tbl original values. in while loop @tbl values variables (thanks @count = id looping through records), , insert them @tbl2
sql sql-server tsql webforms
No comments:
Post a Comment