Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


if i have 1000 records and i want to access 20 ata time
from SQL server, what will be the query?

Answers were Sorted based on User's Feedback



if i have 1000 records and i want to access 20 ata time from SQL server, what will be the query?..

Answer / vijendra singh

Use The following Query for the problem...

Declare @PageIndex int
set @PageIndex=1
Declare @PageSize int
set @PageSize=20
while @PageIndex < 1000
begin
SELECT * FROM test WHERE ID between
@PageIndex and @PageIndex+@PageSize-1
set @PageIndex = @PageIndex + 20
end

Is This Answer Correct ?    13 Yes 2 No

if i have 1000 records and i want to access 20 ata time from SQL server, what will be the query?..

Answer / santosh

u can easily done by the use of Row_number() in sqlserver.

Ex:-

declare @Lower_Bound int,@Upper_bound int
SET @Lower_Bound=1 -- change this as per requirement
SET @Upper_bound=20 -- change this as per requirement
Select Id,Name from(select row_number()over(order by id asc) as Temp_Id,Id,Name from M_Student)
M_Student where Temp_Id >=@Lower_Bound and Temp_Id<=@Upper_bound


Here My Table Name is M_Student(Id,Name) & I have made a Temporary Id column(Temp_Id).Here the result.
Thank U......

If any query then u can connect me through

santosh.primetechsoftware@gmail.com

Is This Answer Correct ?    4 Yes 0 No

if i have 1000 records and i want to access 20 ata time from SQL server, what will be the query?..

Answer / rasbeer

Declare @PageIndex int
set @PageIndex=2

select top 20 * from
(select top 20 * from
(select top (@PageIndex*20) * from chat_contents order by
id ) as a1
order by id desc)as b1 order by id

Is This Answer Correct ?    3 Yes 0 No

if i have 1000 records and i want to access 20 ata time from SQL server, what will be the query?..

Answer / chinnu

select top 20 * from table-name

Is This Answer Correct ?    4 Yes 4 No

if i have 1000 records and i want to access 20 ata time from SQL server, what will be the query?..

Answer / irfan

select * from table name where rownum <= 20;

Is This Answer Correct ?    1 Yes 1 No

if i have 1000 records and i want to access 20 ata time from SQL server, what will be the query?..

Answer / sunny

Assume EMP is my Table where 1000 Records there. We retrive
20 top record from database through by following c# code.
}
sqlconection cn = new sqlconnection(@"Conection string...");
dataset ds = new dataset();
SqldataAdapter da = new SqldataAdapter("select top 20 *
from Emp", cn);
da.fill(ds);
Gridview1.datasource = ds.table[0];
Gridview1.databind();
}

Is This Answer Correct ?    2 Yes 3 No

if i have 1000 records and i want to access 20 ata time from SQL server, what will be the query?..

Answer / gowtham

you can also use Set Rowcount keyword to fetch the records
from sql server.Here is the query for that:

Set Rowcount 20
Select Empname from emp
Set RowCount 0

Is This Answer Correct ?    6 Yes 8 No

if i have 1000 records and i want to access 20 ata time from SQL server, what will be the query?..

Answer / raj

select top 20 * from tablename order by newid()

Is This Answer Correct ?    1 Yes 5 No

if i have 1000 records and i want to access 20 ata time from SQL server, what will be the query?..

Answer / arunbhararthi

you can use top keyword to fetch the first 20 records from
sql server.Here is the query for that:

for example:
select top20 empname from emp.

Is This Answer Correct ?    5 Yes 10 No

Post New Answer

More ASP.NET Interview Questions

please give a brief knowledge about these events ? page_render() page_prerender() page_unload page_loadcomplete page_preinit

1 Answers   Netsweeper,


What is viewstate in asp net with example?

0 Answers  


What are tuples?

0 Answers  


What is State Management in .Net and how many ways are there to maintain a state in .Net?

6 Answers  


What are custom controls?

0 Answers  


What is the difference between repeater over datalist and datagrid ?

1 Answers  


What is owin authentication?

0 Answers  


How to Insert a TextBox value in to Sql database using C# coding?

17 Answers   HCL, Sona, TCS,


What is difference between session and cookie?

0 Answers  


Can more than one person use the same login?

0 Answers   MCN Solutions,


Is asp.net outdated?

0 Answers  


What is application variable and when it is initialized ?

4 Answers   Keane India Ltd,


Categories