在SQL Server中将“身份"列重置为零? [英] Reset Identity column to zero in SQL Server?
本文介绍了在SQL Server中将“身份"列重置为零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在SQL Server中将表的身份"列重置为零?
How can I reset the Identity column of a table to zero in SQL Server?
我们如何使用LINQ to SQL做到这一点?
How can we do it with LINQ to SQL ?
推荐答案
DBCC CHECKIDENT (MyTable, RESEED, NewValue)
您也可以执行截断表",但是,当然,这也会从表中删除所有行.
You can also do a Truncate Table, but, of course, that will remove all rows from the table as well.
要通过L2S做到这一点:
To do this via L2S:
db.ExecuteCommand("DBCC CHECKIDENT('MyTable', RESEED, NewValue);");
或者,您可以从L2S调用存储过程来实现
Or, you can call a stored procedure, from L2S, to do it
这篇关于在SQL Server中将“身份"列重置为零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文