Select Page


hello,

i have following table:

 

  create table dbo.errors  (   id int identity not null,    constraint errors_id_pk primary key clustered (id),   [application] nvarchar(60) not null,   content nvarchar(max) not null,    created datetime not null,   host nvarchar(50) not null,   [message] nvarchar(500) not null,   [source] nvarchar(60) not null,   [status] int not null,    [type] nvarchar(100) not null,    [user] nvarchar(50) not null  ) -- errors  

 

i need "page of errors" given pageindex , pagesize.

so if pageindex = 20 , pagesize = 10 start @ the twentieth item , take 10 items.

i can't use id index because if delete item, example id = 5, the twentieth item not coincide id.

how can this? need change in table?

thank you,

miguel

 

 

  with cte as (select id, [application], content, created, host,   [message], [source], [status], [type], [user],  row_number() over (order by id) as rn from errors) select id, [application], content, created, host,   [message], [source], [status], [type], [user] from cte where rn between @pageindex and @pageindex + @pagesize - 1;  
tom


SQL Server  >  Transact-SQL



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........