Reset Identity column to zero in SQL Server?

前端 未结 6 2339
不知归路
不知归路 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:41

    To accomplish the same task in a SQL Compact table use:

    db.CommandText = "ALTER TABLE MyTable ALTER COLUMN Id IDENTITY (1,1)";   
    db.ExecuteNonQuery(  );
    

提交回复
热议问题