Shezad Ahmed
asked on
Create Unique Reference on SQL Column
Hi Guys
I have a Table called Person.
In Person I have a column called UniqueRef.
The UniqueRef will start with LA00000001.
I need to create a sequential number.
So the next ref will be LA00000002 etc.
Thanks.
I have a Table called Person.
In Person I have a column called UniqueRef.
The UniqueRef will start with LA00000001.
I need to create a sequential number.
So the next ref will be LA00000002 etc.
Thanks.
Why dont you create an identity column and display the column like this 'LA00000001'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is this column the primary key? if so then go with anees's suggestion above and make it an identity column and just format the value as needed with something like:
'LA' + RIGHT('00000000' + UniqueRef, 8)
If this is not the case then I would just include the logic for determine the value of UniqueRef in the procedure that should be handling your insertions in that table.
'LA' + RIGHT('00000000' + UniqueRef, 8)
If this is not the case then I would just include the logic for determine the value of UniqueRef in the procedure that should be handling your insertions in that table.