如何按顺序获取标识列值

编程入门 行业动态 更新时间:2024-10-26 06:39:41
本文介绍了如何按顺序获取标识列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

某些连续的vales被删除我想使用那些值

some sequential vales are deleted i want to use those values

推荐答案

你不能,暂时禁用身份 - 如果你在多用户环境?如果两个人决定同时重新使用旧号码,你可能会回来同样的问题,你试图使用身份字段来避免.... 如果你需要一个反映记录数量中行位置的数字,那么使用ROW_NUMBER函数: You can''t, without disabling the identity temporarily - and what if you are in a multiuser environment? If two people decide to re-use the old number at the same time, you could be back with teh same problem you are trying to use identity fields to avoid.... If you need a number which reflects a rows position in the number of records, then use the ROW_NUMBER function: SELECT Id, Customer, date, Value, @@ROWCOUNT as 'Row Count', ROW_NUMBER() OVER (ORDER BY Id) AS 'Row Number' FROM Customers

这会随着您插入和删除记录而有所不同,但身份值可以保留安全而独特。

That will vary as you insert and remove records, but the identity value can remain safe and unique.

更多推荐

如何按顺序获取标识列值

本文发布于:2023-07-16 20:11:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1125425.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标识   顺序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!