I am trying to auto generate a document reference number when a new document is added to an sql table - the reference number is a concatonation of some of the other fields in that table.
Looking online i can see one method is to use the dbid function to generate a uid and then create a function to concatonate and then a trigger on the table on insert to populate the column, but ive spent numerous hours and i cant get it to work.
The table has the following columns:-
Table:- dbo.codeallocations21322
Columns :-
Dbid
Projectcode
Type
Discipline]
Hdlreference
So the hdlreference column would be populated with :-
[projectcode]-[type]-[discipline]-[bdid]
With the [bdid] set to 6 characters'.
Eg 21322-rfq-mech-000001
Any help would be much appreciated / advise a better way ?
Many thanks in advance.
dbo.. Please tag your DBMS in future