如何在没有程序的情况下生成序列ID

时间:2011-04-04 09:32:17

标签: sql-server-2005

SELECT
  ID
  ,sender
FROM 
SELECT 'squence ID' AS ID, 'blabla' AS sender
FROM A

问题:是否有可能以某种方式生成'序列ID'而无需任何程序?

1 个答案:

答案 0 :(得分:2)

您可以使用row_number(),如下所示:

SELECT row_number() over (order by sender) as Id, 'blabla' AS sender
FROM A