Controversy in SQL 2005 & SQL 200 !!!!

  •             i've written a code in SQL 2005 as:

    SELECT

    *

    FROM

    (SELECT ROW_NUMBER() OVER (ORDER BY date)

    AS Row,phone_no,model,cur_version,version,date,download,version_download,count FROM nokia_supported)

    AS LogWithRowNumbers

    WHERE

    Row >= 1 AND Row <= 10

    it works fine and give the output of first 10 datas... Through this i did the JSP Paing and i got it... But i've to put it on the server side, on the server there is SQL 2000 and it is not executing this on SQL 2000. I'm in trouble, now at this time i can't re-write the whole code which i wrote. Could anyone tell me how to get rid of this problem. In the SQL 2000, it's giving error as:  'ROW_NUMBER' is not a recognized function name. By ammending a little bit can it work or some other keyword is there for the replacement of ROW_NUMBER, kindly help me out.....

     

    in advance thanks a lot......

  • Row_Number is a new feature in 2005. there's no function in 2000 that does that.

    You can try top. Something like

    SELECT TOP 10

    phone_no,model,cur_version,version,date,download,version_download,count FROM nokia_supported

    ORDER BY Date

    It's the closest you're going to come without temp tables and identity columns

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • In 2000 if you want row number then you have use identity column and a temp table...

     

    SELECT TOP 10 identity( int) as rownumber, phone_no,model,cur_version,version,date,download,version_download,count into #test FROM nokia_supported

    ORDER BY Date

    select * from #test

     

    MohammedU
    Microsoft SQL Server MVP

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply