Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Autonumber in SQL

Author  Topic 

jsc0624
Starting Member

13 Posts

Posted - 2007-04-25 : 04:23:03
[CODE]create table tblCasCodeDef(
CasCodeDefID int not null,
CasCodeDef char(100),
CasDescription char(200),
EngineeringFunction char(100),
Primary Key (CasCodeDefID));[/CODE]

In this code, how can I make my CasCodeDefID as autonumber?


===============
JSC0624
===============

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-25 : 04:26:29
[code]
create table tblCasCodeDef(
CasCodeDefID int identity not null,
CasCodeDef char(100),
CasDescription char(200),
EngineeringFunction char(100),
Primary Key (CasCodeDefID));
[/code]


KH

Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-04-25 : 12:46:28
KH's code above will start the IDentity values with 1 and increment by 1, by default. If you need to start elsewhere and increment by something else..


create table tblCasCodeDef(
CasCodeDefID int identity(500,5) not null,
CasCodeDef char(100),
CasDescription char(200),
EngineeringFunction char(100),
Primary Key (CasCodeDefID));



************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -