如果c#中的表为空,如何查找标识列的最大种子 [英] How to find max seed of identity column if table is empty in c#

查看:72
本文介绍了如果c#中的表为空,如何查找标识列的最大种子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果表没有行(即空),我想找到一个标识列的最大种子。



例如如果一个表有10行,则在(1,1)的情况下最大标识将为10,如果我们删除所有行并重新插入一行,则标识将为11.在这种情况下我想找出身份值10(最大身份)无论桌子是空的。



请帮助



谢谢

I want to find max seed of an identity column if table has no rows(i.e. empty).

e.g. if a table has 10 rows ,the max identity will be 10 in case of(1,1) ,If we delete all rows of table and re-insert a row ,the identity will be 11. In this case i want to find out identity values 10(max identity) no matter table is empty.

Please help

Thanks

推荐答案

您可以使用以下功能 -



You can use the below function -

SELECT IDENT_CURRENT('ProductMaster')





而不是ProductMaster传递你的表名



Instead of ProductMaster pass your table name


你也可以使用 - DBCC CHECKIDENT(Transact-SQL) [ ^ ]检查当前标识值并根据需要进行更改。
You can also use - DBCC CHECKIDENT (Transact-SQL)[^] to check the current identity value and change it, if required.


这篇关于如果c#中的表为空,如何查找标识列的最大种子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆