Mons Posted March 30, 2006 Share Posted March 30, 2006 Hi, another newby here! and still learning sqlI am creating a database in sql server 2000 using Query Analyzer and I would like to have a column auto increment, Is this possible in the CREATE TABLE statement, or must it be handled in the program layer? and if the sql can handle it how would I go about it?The column in question is "isIssueCode" and my CREATE statement is below.if exists (select * from dbo.sysobjects where id = object_id(N'[issue]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [issue]GOCREATE TABLE [issue] ( [isIssueCode] [nchar] (10) NOT NULL , /* This column */ [isContactCode] [nchar] (10) NOT NULL , [isTCStaffCode] [nchar] (10) NOT NULL , [isTCReference] [nvarchar] (50) NOT NULL , [isDateRecieved] [datetime] NOT NULL CONSTRAINT [DF_Issue_isDateRecieved] DEFAULT (getdate()), [isDateClosed] [datetime] NOT NULL CONSTRAINT [isDateClosed] DEFAULT ('2777-07-07'), CONSTRAINT [PK_Issue] PRIMARY KEY CLUSTERED ( [isIssueCode] ))GOThankyou in advanceMons Link to comment Share on other sites More sharing options...
aspnetguy Posted March 30, 2006 Share Posted March 30, 2006 Sql server does not have the autoincrement property, it has IDENTITY which does the same thing.http://msdn.microsoft.com/library/default...._ia-iz_3iex.asp Link to comment Share on other sites More sharing options...
Mons Posted March 30, 2006 Author Share Posted March 30, 2006 Thankyou aspnetguy!!That works very well indeed Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now