Query to get a particular row in Sql Server 2005

By Ankit Goyal | May 19, 2009 | 1,711 views
Category .NET, Database


About author  Working on .NET technologies for past 2yrs. I am very passionate about the new features which get introduced in the technology. I am here to share the new features i get to know in the world of Microsoft. Follow me on twitter @ankygoyal Read more from this author


In this article we will look into how to write a sql query to get a particular row in sql.

Lets write the code to find 2nd row in a table named mcc_measures.

So first we declare a temporary table

declare @temp table (id int)

No in this temp table we insertrow numbers of the table


insert into @temp(id)

SELECT
ROW_NUMBER() over(ORDER BY Measure_Id DESC)
FROM
mcc_measures

Now from the temp table we select the row where rowid=2 as required

SELECT
*
FROM
@temp
WHERE
id = 2

kick it on DotNetKicks.com

Shout it

pimp it

Read more post on Microsoft sql server 

5 comments | Add One

Comments

  1. KattyBlackyardNo Gravatar - 06/15/2009 at 10:42 am

    Original post by Dmitri Gromov



  2. Ankit GoyalNo Gravatar - 06/19/2009 at 4:22 am

    Hi KattyBlackYard,

    Well the query written above is very basic query and i do not know what Dmitri Gromov has written on the topic.
    Please provide me the URL of the article you are talking of, so that i can send pingbacks to it.



Trackbacks

  1. DotNetBurner - SQL Server
  2. DotNetShoutout
  3. PimpThisBlog.com

Leave a Comment

Name:

E-Mail :

Website :

Comments :