ehsankhan ehsankhan - 1 year ago 106
SQL Question

row_number() function

How to use the

row_number
function in a view?

I use it like this:

SELECT
ROW_NUMBER() OVER (ORDER BY name ASC),
name, family, mobile, tell
FROM
dbo.customer


but SQL Server throws this error:


SQL text cannot be represented in the grid pane and diagram pane.

Answer Source

You can use row_number() in a view, but you need to give it a name to use in a view:

SELECT row_number() over (order by name asc) as seqnum,
       name, family, mobile, tell
FROM dbo.customer;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download