Skip to content Skip to sidebar Skip to footer

Would Like To Generate Custom Unique Key And Handle It Multiple Request At Same Time

I have a table as below in sql database server which containing a varchar column and maintaining it as custom unique key programattically using linq to entity. I am pulling from da

Solution 1:

what will happes when multiple request comes at same time

You will get a PK violation.

In SQL Server you can use a Sequence object to generate the key like this:

create sequence seq_t
startwith1
increment by1createtable t
(
  id varchar(20) default concat('BA',format((next valuefor seq_t),'0000')) primary key, 
  a int
)

Post a Comment for "Would Like To Generate Custom Unique Key And Handle It Multiple Request At Same Time"