Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2007-01-11 : 06:48:33
|
| Mike writes "Hello,I am working on an accounting system using VB.NET and sql server 2005 as a database. the application should be used by multiple users.i have a the following structure: Voucher: ID (primary), Date,TypeID, ReferenceCode, .....Type: ID, Code, Name. (the user can add new type anytime!)(Ex: PV- payment voucher, JV - Journal Voucher ,....)When adding a voucher the user will choose a type, according to this type (for each year) a counter will be increminted.for example: PV1, PV2....PV233,... the other type will have its separate counter JV1, JV2 ,...JV4569,..I am using the sqlTransaction cause i am doing other operations that should be transactional with the insertion of the Voucher.The question is : What is the best solution to generate a counter for each type?(With code sample)Thanks." |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-11 : 06:58:17
|
| Using an IDENTITY column, and add prefix 'PV' or 'JV' in second column according to the type of voucher.Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|
|