newid() inside sql server function

后端 未结 4 2297
旧巷少年郎
旧巷少年郎 2020-11-27 03:24

I have to insert a fake column at the result of a query, which is the return value of a table-value function. This column data type must be unique-identifier. The best way (

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 04:15

    You could use ROW_NUMBER function:

    SELECT
    (ROW_NUMBER() OVER (ORDER BY recordID) ) as RowNumber ,
    recordID,
    fieldBla1
    FROM tableName

    Find more information at http://msdn.microsoft.com/pt-br/library/ms186734.aspx

提交回复
热议问题