Solved

start records at a new number

Posted on 2014-01-29
4
252 Views
Last Modified: 2014-01-29
I have a table that contains data. I started the identity seed at 4000. Is there a way to have brand new records start at 5000?
0
Comment
Question by:NickMalloy
4 Comments
 
LVL 15

Accepted Solution

by:
tim_cs earned 300 total points
ID: 39819178
DBCC CHECKIDENT (TableName, RESEED, 4999)
0
 
LVL 16

Expert Comment

by:Surendra Nath
ID: 39819186
solution

you can change your identity seed to 5000 as shown below

DBCC CHECKIDENT ('<yourtable.YourColumn>', RESEED, 5000);
0
 
LVL 31

Expert Comment

by:James Murrell
ID: 39819187
i use reseed

something like DBCC CHECKIDENT (TableName, RESEED, 4999)
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39819202
The high-tech answer would be DBCC CHECKIDENT
CREATE TABLE #tmp (id int identity(1,1), label varchar(50))

INSERT INTO #tmp (label) VALUES ('one'), ('two'), ('three')

DBCC CHECKIDENT (#tmp, RESEED, 999)

INSERT INTO #tmp (label) Values ('one thousand')

SELECT * FROM #tmp

Open in new window

The low-tech answer would be to just insert and delete however many rows get you to 4,999.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now