Reputation: 225
I want to create table called entries with the following fields. entry_id, and entry. Making entry_id the primary key field with data type of int. but before the primary keys are being generated i want there to be a value of 000 for the primary key starts counting. for example 0001,0002 and so forth
Upvotes: 0
Views: 69
Reputation: 10452
On the database your identity will have to be an integer without the padding. If you want padding, you will have to pad it with 0's either when pulling the values from the db or when displaying them in your UI.
Create a table with an identity:
CREATE TABLE employee
(
id int IDENTITY(1,1),
firstname varchar (20),
middleinitial char(1),
lastname varchar(30)
);
To reseed at 0 if you need to, you can execute:
DBCC CHECKIDENT ( ‘databasename.dbo.yourtable’,RESEED, 0)
Upvotes: 1