最大主键值 [英] MAX PRIMARY KEY VALUE
本文介绍了最大主键值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有包含ID作为主键的Table1.
现在,如果我删除ID 2和3的条目,请说.
现在,下一个要使用的ID是4.
问题:在将新记录插入表之前,如何确定此ID值(4).
删除了大喊大叫.
Suppose I have Table1 which contains ID as primary key.
Now if I delete the entry say for ID 2 and 3.
Now the next ID which is going to be used is 4.
Question: How do I determine this ID value (4) before a new record is inserted into the table.
removed shouting.
推荐答案
退出类似的内容,我们在这里进行了讨论.
sql查询返回主键 [
Quit similar thing we have discuss here.
sql query return primary key[^]
使用@@Identity
.请参见此处 [
尝试一下.
Try this.
SELECT IDENT_CURRENT('tablename') + IDENT_INCR('tablename')
这篇关于最大主键值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文