Reset Identity column to zero in SQL Server?

前端 未结 6 2296
不知归路
不知归路 2021-02-19 04:36

How can I reset the Identity column of a table to zero in SQL Server?

Edit:

How can we do it with LINQ to SQL ?

6条回答
  •  悲&欢浪女
    2021-02-19 04:54

    Use the LINQ to SQL ExecuteCommand to run the required SQL.

    db.ExecuteCommand("DBCC CHECKIDENT('table', RESEED, 0);");
    

    LINQ is a data-source agnostic query language and has no built-in facilities for this kind of data-source specific functionality. LINQ to SQL doesn't provide a specific function to do this either AFAIK.

提交回复
热议问题