-
Feb 24th, 2014, 11:46 PM
#1
Thread Starter
Lively Member
[RESOLVED] Help Needed to save continuous number based on 2 types on entries in a single table ?
SQL SERVER 2000:
I need to save 2 kinds of the same bill to a tables called bills. But each kind should have same continuous bill numbers.
Meaning if A and B are the two kinds, both should have continous bill numbers. But one type of bill should not have same bill number .Also should not skip a number too.
Example A should have 1,2,3... and B should have 1,2,3... They cannot have 1,1,2 for the same type. Also it should not skip a number like A:1,3,5 B:2,4 etc.
Note that I cannot take max of one type because it would cause same bill number when there are many users involved
How can I achieve this?T.Y.
LOOKS LIKE I POSTED IT IN WRONG CATEGORY. PLEASE MOVE IT TO DATABASE CATEGEORY.
Last edited by BlueFox; Feb 24th, 2014 at 11:47 PM.
Reason: WRONG CATEGORY
-
Feb 25th, 2014, 02:20 PM
#2
Re: Help Needed to save continuous number based on 2 types on entries in a single tab
Thread moved to the 'Database Development' forum
-
Feb 25th, 2014, 02:58 PM
#3
Re: Help Needed to save continuous number based on 2 types on entries in a single tab
Note that I cannot take max of one type because it would cause same bill number when there are many users involved
No it won't and this is, in fact, your answer. You just need to either wrap it in a transaction or, even better, select the max id as part of the insert statement. Something like this:-
Code:
Insert Into Table
(ID)
Select Max(ID) + 1
From Table
Because that's a single statement it will be resolved without any risk of interleaving with other users.
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|