Friday 15 July 2011

c# - Customize Auto_Increment using prefix YYYY-0000001 [SQL] -



c# - Customize Auto_Increment using prefix YYYY-0000001 [SQL] -

is simple way auto generate project id 0001, 0002, 0003 instead of 0001 2014-0000001, 2014-0000002, 2014-0000003 ...

userid = {year}-{0000001} > continuous.

sample:

userid | name 2014-0000001 | gary 2014-0000002 | alrey

or generating csharp/c# function much easy manully inserted table latest userid , increment base of operations on year? can suggest.

i have here sql command working when year pass wont reset 1. have thought when counting rows year current date.

create table test( testid int identity(1,1) not null, testprefixid (convert([varchar], year(current_timestamp), 0)) + '-' + right('000000'+convert([varchar],testid,0), (6)), name varchar(100) not null, constraint pk_teacher primary key (testid) )

thanks in advance.

c# sql-server function unique auto-increment

No comments:

Post a Comment