Auto Incrementing Values

  • Thread starter Thread starter Lora Connors
  • Start date Start date
L

Lora Connors

I have an Invoice table in my database with 'InvoiceID' as
its primary key. I would like the InvoiceID field to auto
increment values in the format INV1, INV2,
INV3........INV100.so on and so forth. How do I go about
it?
Thanks!
 
Hi Lora,

That is a bad idea. Why don't you use numbers instead?
Anyway, you'll have to find the max key before inserting INVMAX+1.

select max(cast(substring(inv, 4,100) as numeric)) from tral
Will give you last inv number.
You should then increase it and insert INV+(MaxNumber+1).ToString() into
DataTable or something.
 
Back
Top