从MSSQL表获取主键的值 [英] getting the value of the primary key from MSSQL table
本文介绍了从MSSQL表获取主键的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请我希望有人帮助我找到如何从MSSQL表中获取下一个值或主键的值,如果有人知道答案的话,我将不胜感激:)
please i want someone to help me finding how can i get the next-value or the value of the primary key from the MSSQL Table, please if anyone knows the answer i would be thankful :)
推荐答案
Select MAX(PrimarykeycolumnName)+1 FROM tableName
是吗?
Is it ?
如果您使用的是SQL Server 2008,则可以使用以下查询来获取表的下一个标识值
If you are using sql server 2008, then you may use the following query to get the next identity value of the table
select IDENT_CURRENT('categories')+IDENT_INCR('categories')
其中类别"是您想要下一个标识值的表名.
where ''categories'' is the table name for which you want next identity value.
这篇关于从MSSQL表获取主键的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文