VB.NET - how to increment alphanumeric value from sql database during form load

Asked By fudely v on 24-Oct-13 02:05 AM
hi,,,
how to increment alphanumeric value during form load.


for example ,
  employee id emp001,emp002 in sql database ,then how to get incrememt string during form load
Robbe Morris replied to fudely v on 24-Oct-13 09:53 AM
Alas, another stupid database design.  I realize this probably isn't yours and I feel your pain.  The easiest way to rectify this going forward is to create a new column of int or bigint (depending on how many gazillion records are in the table) and set it to Identity Seed on.  Set the initial seed to be one higher than the max emp id that currently exists in your table.

Then, create an insert trigger that updates your employeeid field with "emp" + whatever the new identity seed column value is.

Keep this in mind for other areas of your app.  A "string" is not ordered by the same way an int/bigint is.  So, you want to perform your order by's going forward on your new Identity Seed column.