我想创建行号,但我不想使用任何指定的列(或未标识的列名)。像下面的东西
SELECT ROW_NUMBER() OVER(ORDER BY '*'), * FROM DIM_BRANCH
我怎样才能做到这一点?
答案 0 :(得分:3)
就像这样
SELECT ROW_NUMBER() OVER(ORDER BY (Select Null)), * FROM DIM_BRANCH
答案 1 :(得分:2)
SELECT ROW_NUMBER() OVER(ORDER BY @@rowcount), * FROM DIM_BRANCH
如果您想要更随机的行为:
SELECT ROW_NUMBER() OVER(ORDER BY NEWID()), * FROM DIM_BRANCH