0

In my application i have few documents types Inovice, Order , Shipping. All this types need to have own prefix in database with number of document. Somthing like ID auto increment but not that.

When i create order i need to auto generate order number like SO-000001 and next time when i create again new order must be SO-000001. The some for Inovice and Shipping documents. This is not auto increment. How to to create this? Does i must create trigger or i need that to do via code in my app?

enter image description here

Ivan
  • 5,139
  • 11
  • 53
  • 86
  • If you need this it is going to be tricky. Are you ready to rollup your sleeves? – Drew Sep 09 '16 at 16:21
  • I used this article once to auto-increment with letters... hope it helps! http://stackoverflow.com/questions/14680122/how-to-auto-increment-id-numbers-with-letters-and-numbers – Shannon Holsinger Sep 09 '16 at 16:22
  • You could use my Intention Lock code here to get your incrementor first http://stackoverflow.com/a/38079598 then prefix it, and do the insert – Drew Sep 09 '16 at 16:24
  • I wouldn't do this in SQL simply code the order number generation code in C# – deW1 Sep 09 '16 at 16:41
  • Since order must not change according to the post (must be "SO-000001") I don't see any problem implementing such code... Can you please clarify? Possibly [edit] as you may have stated your requirements worng (and forgo to show either payment method or your research/attempt to solve it) – Alexei Levenkov Sep 09 '16 at 16:43

0 Answers0