How To: Reset Identity column in SQL Server
来源:互联网 发布:qt tcp 连接的端口号 编辑:程序博客网 时间:2024/04/29 11:30
This is one of those simple tip posts that may seem obvious and taken for granted by those of us who have been working with SQL Server for a while now but maybe a newbie or two out there will find this helpful.
Every so often (just this morning!) I find myself resetting an identity column value back to 0 after I've deleted all the existing records so the table gets a fresh start at primary key 1. Yes, I know all about primary keys not changing and how the value in the primary key doesn't matter and so on. Sometimes I just like the primary keys starting at 1.
The following line resets the Identity value for the Customer table to 0 so that the next record added starts at 1.
DBCC CHECKIDENT('Customer', RESEED, 0)
Every so often (just this morning!) I find myself resetting an identity column value back to 0 after I've deleted all the existing records so the table gets a fresh start at primary key 1. Yes, I know all about primary keys not changing and how the value in the primary key doesn't matter and so on. Sometimes I just like the primary keys starting at 1.
The following line resets the Identity value for the Customer table to 0 so that the next record added starts at 1.
DBCC CHECKIDENT('Customer', RESEED, 0)
- How To: Reset Identity column in SQL Server
- How To Split column In SQL
- MS SQL Server - How to change an existing column to auto-increment column
- how to reset sys password in oracle
- How to reset password in ubuntu
- How to reset your password in Ubuntu
- How to reset usb device in linux
- How to Reset USB Device in Linux
- SQL Server中IDENTITY类型字段的Reset
- how to add linked server in SQL server.
- How To Use Dynamic Sql in Sql Server ?
- Linq to SQL how to do “where [column] in (list of values)”
- HOW TO : Select column in Notepad++
- Summary on 20080701: insert value for identity column in sql
- How to search the available space in SQL server.
- How to delete duplicate rows without children in sql server
- How to shrink the tempdb database in SQL Server
- How to enable remote connections in SQL Server 2008?
- 敬业精神
- C#中毫米与像素的换算方法
- javascript cookies 保存、获取和删除
- 从奥运订票系统瘫痪说起——谈FastCGI 与IT 架构(转)
- 一个合格程序员该做的事情
- How To: Reset Identity column in SQL Server
- 算法
- "已有打开的与此命令相关联的DataReader,必须首先将它关闭"问题解决
- SYBASE的一些知识
- 英文圣诞祝福
- 用于图像识别的EBM(Energy-Based Model)的简要说明
- Eclipse 快捷键
- 使用AJAX技术实现google suggest学习笔记
- [英语阅读]平安夜美国犹太单身大聚会