-2

i have an integer value id, it is okay and it is taking the value by default like 1,2, 3..... now i want to take this value like this 0001, 0002,0003. how can it possible please help me.

 USE [Companybook]
    GO

    /****** Object:  Table [dbo].[Employees]    Script Date: 12/05/2013 14:50:14 ******/
    SET ANSI_NULLS ON
    GO

    SET QUOTED_IDENTIFIER ON
    GO

    CREATE TABLE [dbo].[Employees](
        [EmployeeID] [int] IDENTITY(1,1) NOT NULL,
        [LastName] [nchar](10) NULL,
        [FirstName] [nchar](10) NULL,
        [Country] [nchar](10) NULL,
     CONSTRAINT [PK_Employees] PRIMARY KEY CLUSTERED 
    (
        [EmployeeID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]

    GO
Abdul Hamid
  • 121
  • 1
  • 1
  • 11

1 Answers1

0

Hi you cant use 0001 as Identity in Sql, instead of that you can use valid number like 1001,2001,3001......

But you can retrieve the id as you said...

Please refer the link: http://social.msdn.microsoft.com/Forums/en-US/9ae39780-9e95-4e91-bd9f-9f9fc9232084/how-to-make-int-identity-field-showed-like-0001-

http://forums.asp.net/t/1625788.aspx

Vignesh Kumar A
  • 27,863
  • 13
  • 63
  • 115