how To Create Auto Generated Unique Identity Code in a SQL Table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vinay22
    New Member
    • Jun 2007
    • 1

    how To Create Auto Generated Unique Identity Code in a SQL Table

    how To Create Auto Generated Unique Identity Code in a SQL Table , when i Insert Data into TAble
  • Purple
    Recognized Expert Contributor
    • May 2007
    • 404

    #2
    Hi vinay22 and welcome to TSDN !

    take a look at the following:

    Code:
    CREATE TABLE [dbo].[auto_inc_example] (
    	[field1] [int] IDENTITY (1001, 1) NOT NULL ,
    	[field2] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    	[field3] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
    ) ON [PRIMARY]
    GO
    notice field1, defined as an int, Identity keyword first parameter the startpoint for the identity value, second for the increment value for each record.

    Hope this helps

    Purple

    Comment

    Working...