RE: FN-FORUM: Autonumber in sql server
date posted 21st January 2007 15:52
>> I'm using SQL Server Express Edition and was wondering if anyone here
knew
how to create an autonumber start at a set number as opposed to the default
0, for example start counting from 1000 instead of 0?
_________________________________________
James,
If you're using SQL to create the table, you can do it in the create script,
for example:
CREATE TABLE dbo.Table_1
(
Table_1ID int NOT NULL IDENTITY (1000, 1),
TableCol1 nchar(10) NULL,
TableCol2 nchar(10) NULL
) ON [PRIMARY]
GO
The first parameter after the IDENTITY statement (IDENTITY is what SQL
Server calls an autonumber) is the 'seed' value - the value at which the
identity starts. So in the example above, the first id would be 1000, then
1001, 1002, and so on.
Cheers,
Andrew.
--
_____________________________
Andrew Bibby
I.T. Solutions Ltd
http://www.itsolutions.uk.com