ROW_NUMBER() in a view in SQL Server 2005

2019-09-02 06:43发布

问题:

I have tried the following query in Microsoft SQL Server Management Studio:

select 
   ROW_NUMBER() OVER(ORDER BY ret_id, dep_id DESC) AS 'Row Number' 
from 
   Round_Trip_View

and it works.

I have tried the same to create a view, and it crashed.

Any idea?

I am looking to assign a kind of id for each row in my view and I appreciate any alternative ideas :)

回答1:

The problem was the view wizard.
What I learned: never use the wizards when you can code! :)