Click here to Skip to main content
15,881,455 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

I Want to increment by 1 with character like (MA1, MA2, MA3)

in register table i want this
memebr id have to look like this format

member_id
==========
MA1
MA2
MA3
MA4
...
...

how can i do this ??
Posted

I would use an INT Identity field to generate the numbers, and then add a computed column for the username / identity thing:
SQL
CREATE TABLE [dbo].[MyTable](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [member_id]  AS ('MA'+CONVERT([varchar](6),[Id],0)),
    [Name] [nchar](10) NOT NULL
) ON [PRIMARY]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900