Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a table with only 1 column as

Name
A
B
C
D
E
F
G
H
I
J

i want output as 6th to 9th record as- F G H I
Posted

You have to write procedure for this
SQL
CREATE PROCEDURE ReturnRowsAt
(
  @Startpos int,@Endpos int
)
AS 
Begin
 DECLARE @Table1 AS TABLE (rwid bigint identity(1,1), val nvarchar(255))

INSERT INTO   @Table1 (val)
 SELECT * FROM  yourtablename

SELECT * FROM    @Table1 WHERE rwid between @Startpos and @endpos
End


Hope this helps if yes then accept and vote the answer
--Rahul D.
 
Share this answer
 
Comments
The Doer 17-Feb-12 6:04am    
THATS IT BUDDY...! 5!
The Doer 17-Feb-12 6:12am    
HERE I HAVE ONLY 1 COLUMN, SUPPOSE I HAVE 20 + COLUMNS THEN WHAT WILL U DO?
RDBurmon 17-Feb-12 7:44am    
Then you have to add columns in this two lines

DECLARE @Table1 AS TABLE (rwid bigint identity(1,1), val nvarchar(255), val2 nvarchar(255), val3 nvarchar(255) .....
............................)

INSERT INTO @Table1 (val,val2,val3................................)
Try this:
SQL
SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY column_name) AS RowNum, * FROM Table_name) sub WHERE RowNum between 6 and 9
 
Share this answer
 
Comments
The Doer 17-Feb-12 6:02am    
IF THIS IS MY TABLE CONTENT, I DONT WANT THE ORDER TO BE CHANGED,AS U CHANGED USING ORDERbY CLAUSE..AGAIN I WANT FROM 6TH TO 9TH RECORD i:e B C D a..TRY SOME MORE..

a
B
C
D
E
B
C
D
a
B
C
D
a
B
C
D
E

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900