I want to generate a unique id for a student based on the department of the student.
I want student Id to be CS0448 when department id is CS,and IT0448 for department id IT and so on.And these IDs must increment by 1 .
I thought that I will have another identity and autoincrement it by 1 for each student added and concatenate it with department Id,but that wont help me.It will cause IT student added next to CS0448 to be IT0449. Please help me with this. see this…it must be something like this..
...
cs0439
it0441
cs0440
it0442
cs0441
cs0442
Please let me know the better options for a alphanumeric identity
You could try an INSTEAD OF INSERT trigger, like this:
Results: