本文介绍了如何在SQL Server中重置身份规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个表格ABC和列EmployeeId和薪水.
我已经设置了员工ID的身份.
并在表中将值插入为
Hi All,
I have a table ABC and Column EmployeeId and salary.
I have set identity of Employee Id.
and have inserted values in tables as
1 455454
2 45454
3 4545454
4 5656565
5 4545454
现在,如果我删除第四个记录,然后插入一个新记录,则显示为:
1 455454
2 45454
3 4545454
5 4545454
6 56565645
但我希望它不是4
1 455454
2 45454
3 4545454
4 56565645
5 4545454
请让我知道该怎么做.
谢谢你
Mohammad Wasif
Now if I delete record at no four and insert a new record then it shows as:
1 455454
2 45454
3 4545454
5 4545454
6 56565645
but I want it as no 4
1 455454
2 45454
3 4545454
4 56565645
5 4545454
Please let me know how to do it.
Thanking You
Mohammad Wasif
推荐答案
INSERT INTO ABC (EmployeeId, Salary)
SELECT MAX(EmployeeId)+1
, [YourSalaryValue]
FROM ABC
这篇关于如何在SQL Server中重置身份规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!