SolutionCottage.com
Posted  29 Apr 2009 - 09:38:55

Category: SQL


How to make an auto incrementing field with specified number

Issue:
You want to have a field incrementing, maybe starting with another value than default and also change the amount to increment each time.

Solution
This is the code to do this:

ALTER TABLE Basket ADD OrderNr BIGINT IDENTITY(1000000,1) NOT NULL;

The IDENTITY keyword tells SQL server to increment the field. The first argument (1000000) is the number to start at and the second argument (1) is the amount to increment the number with.








0 comments:








© SolutionCottage 2008-2011 9/24/2017 12:59:43 PM