that error could occur if your database compatibility level is at 80 instead of 90;
the compatibility level determines which syntax version is applied to statements hitting the database, and rownnumber() is a 90 and above functionality.
change the version and you should be all set.
I tried your example with sql 2005 but it gives me this error
Msg 195, Level 15, State 10, Line 1
'ROWNUMBER' is not a recognized built-in function name.
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!