A simple piece of code
 
 This is a code to select the #row from a table.
 For example if you give 2 it will select the second row from the table.
 The procedure is
 
 create procedure SP_FETCH_ROWS(@num int)
 AS
 BEGIN
  select * from employee a where @num=(select count(*) from employee b where a.id >= b.id)
 END
 
 
 The table i am using employee. The structure is
 
 id int
 name varchar(50)
 age int
 sex char(1)
 
 The rows in my table are
 
 id          name                                               age         sex  
 ----------- -------------------------------------------------- ----------- ---- 
 1           shaju                                              25          M
 2           thomas                                           25          M
 3           anil                                                 25          M
 4           ashley                                            25          M
 
 Now when execute the procedure to select the third row
 
 exec SP_FETC...
Posts
Showing posts from October 14, 2003