About author  I am MCPD certified in .NET and working on .NET technologies for past 3yrs. 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 LinkedIN@Ankit Goyal 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

5 Responses to Query to get a particular row in Sql Server 2005


  1. KattyBlackyardNo Gravatar
    Jun 15, 2009

    Original post by Dmitri Gromov


    • Ankit GoyalNo Gravatar
      Jun 19, 2009

      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/Pingbacks

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

Leave a Reply