我有auto_increment(WPF)的问题 [英] I Have A problem with auto_increment (WPF)

查看:67
本文介绍了我有auto_increment(WPF)的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了30行并将其删除,当我创建另一行时,它需要数字31它必须

是1

请帮助我

I create 30 rows and I removed it and when I create another row it take the number 31 it must
be 1
please help me

推荐答案

你需要重新设置你的身份栏。

DBCC CHECKIDENT('myTable',RESEED,0)应该这样做。
You need to reseed your identity column.
DBCC CHECKIDENT('myTable', RESEED, 0) should do the trick.


1.每次添加记录时,以及删除一个或多个记录时,数据库表中的自动增量字段将生成唯一ID用于删除记录的ID不能重新用于添加新记录。但这是这些自动增量字段的正常行为。



2.在你的情况下,如果你已经删除了所有记录,并且你想从1重新启动身份,解决方案是将其值重新设置为从1开始,就像是在上面的第一个解决方案中指出。

有关详细信息,您可以阅读下一个 MDSN链接。 [ ^ ]
1.The auto-increment fields from database tables are made to generate unique ID each time a you record is added, and when one or more records are deleted the IDs used for deleted records cannot be reused for adding new records. But this is the normal behavior for these auto-increment fields.

2.In your case if you have deleted all records and you want to restart the identity from 1, the solution is to reseed its value to start from 1 like is indicated in the 1st solution above.
For more details about this you could read the next MDSN link.[^]


这篇关于我有auto_increment(WPF)的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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