Auto Increment Id's

  • Hi Experts,

    Can you tell me how to increment number for a particular column if same name appears again

    NameID

    John1

    John2

    Ella1

    Gaby1

    Gaby2

    Gaby3

  • Lookup Row_Number() in Books online, it is what you are looking for.

    Cheers,

    J-F

  • No I have a database table which contains Name column and i want to create a temp Table which will hold

    Name and Id column

  • This is exactly what the "Row_Number()" function will allow you to do, read it up in Books Online.

    Cheers,

    J-F

  • Awesome Kool This is what i need

  • Auto Increment Field or Identity Field In MS SQL Server

    Creating a Auto Increment field in SQL Server allows a unique number to be generated when a new record is inserted into a table.

    Syntax for creating an Auto Increment field in SQL Server.

    CREATE TABLE [dbo].[Company](

    [CompanyId] [bigint] IDENTITY(1,1) NOT NULL,

    [Name] [nvarchar](200) NOT NULL,

    [Address] [nvarchar](max) NOT NULL,

    [Phone] [nvarchar](max) NULL,

    [autoBackup] [bit] NOT NULL,

    [applycreditlimit] [bit] NULL,

    [EmailId] [nvarchar](max) NULL,

    [salesTaxPercentage] [numeric](18, 2) NULL)

    Here, CompanyId has been set as an Auto Increment Id.

    A column which has datatype int, big int, tiny int or small int can only be set as an Auto Increment field.

    Suppose, you would like to set the AutoIncrement field (CompanyId) at the remote databases to only use the next number free AFTER the 100.

    Here, CompanyId has been set as an Auto Increment Id.

    A column which has datatype int, big int, tiny int or small int can only be set as an Auto Increment field.

    Suppose, you would like to set the AutoIncrement field (CompanyId) at the remote databases to only use the next number free AFTER the 100.

    There’s an “Identity Seed” parameter that you can specify (either through SQL or through the table designer in Enterprise Manager) that will let you set the base value for an Identity/AutoNumber field to the value you want. Any new Identity values will be incremented from this base (using the “Identity Increment” value which you can specify in the same place to determine how much to grow the value by).

    If you would like to see a video as to how to set the auto increment field in SQL Server, then we have a video tutorial uplaoded at:

    http://www.industrialtrainingkolkata.com/?cat=1

  • Auto Increment Field or Identity Field In MS SQL Server

    Creating a Auto Increment field in SQL Server allows a unique number to be generated when a new record is inserted into a table.

    Syntax for creating an Auto Increment field in SQL Server.

    CREATE TABLE [dbo].[Company](

    [CompanyId] [bigint] IDENTITY(1,1) NOT NULL,

    [Name] [nvarchar](200) NOT NULL,

    [Address] [nvarchar](max) NOT NULL,

    [Phone] [nvarchar](max) NULL,

    [autoBackup] [bit] NOT NULL,

    [applycreditlimit] [bit] NULL,

    [EmailId] [nvarchar](max) NULL,

    [salesTaxPercentage] [numeric](18, 2) NULL)

    Here, CompanyId has been set as an Auto Increment Id.

    A column which has datatype int, big int, tiny int or small int can only be set as an Auto Increment field.

    Suppose, you would like to set the AutoIncrement field (CompanyId) at the remote databases to only use the next number free AFTER the 100.

    Here, CompanyId has been set as an Auto Increment Id.

    A column which has datatype int, big int, tiny int or small int can only be set as an Auto Increment field.

    Suppose, you would like to set the AutoIncrement field (CompanyId) at the remote databases to only use the next number free AFTER the 100.

    There’s an “Identity Seed” parameter that you can specify (either through SQL or through the table designer in Enterprise Manager) that will let you set the base value for an Identity/AutoNumber field to the value you want. Any new Identity values will be incremented from this base (using the “Identity Increment” value which you can specify in the same place to determine how much to grow the value by).

    If you would like to see a video as to how to set the auto increment field in SQL Server, then we have a video tutorial uplaoded at:

    http://www.industrialtrainingkolkata.com/?cat=1

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply