Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generate a unique identity number on insert of a record

Status
Not open for further replies.

venuchalla

Programmer
May 30, 2006
29
FR
Hello,
I have created a table with fields like this
--------------------------------------------------------
CREATE TABLE [dbo].[Issues](
[CreatedByAlias] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Title] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Description] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[ExpireAt] [datetime] NOT NULL,
[CreatedAt] [datetime] NOT NULL,
[Status] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[CompleteTime] [int] NOT NULL,
[MailSent] [nchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_Issues_MailSent] DEFAULT (N'No'),
[NotifyAlias] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[IssueNumber] [int] NOT NULL,
CONSTRAINT [PK_Issues] PRIMARY KEY CLUSTERED
(
[IssueNumber] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

-------------------------------------------------
When I am inserting a record from the form, I need a unique number generated automatically for that record in the table.

How can I do this, Can you please help me with the code.
 
Code:
CREATE TABLE Issues(
......
[IssueNumber] [int] IDENTITY(1,1)
....

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top