Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 18,243 of 19,505    |
|    Gene Wirchenko to All    |
|    SSE 2008: A Special Kind of Identity    |
|    15 Apr 11 13:53:18    |
      XPost: microsoft.public.sqlserver.programming       From: genew@ocis.net              Dear SQLers:               I continue slowly putting together a Banking database. I now       want to define the Transactions table. It makes sense to keep       transactions together somehow. For example, a transfer from one       account to another is composed of a transfer out and a transfer in. It       would be good to be able to see all parts of such a batch.               I suppose that transactions could be corrected after the fact, so       I am really only concerned with a batch balancing when it is entered.       How do I generate the batch number? (I do not want the application       doing this. I want it done in a stored procedure.)               If I have a common attribute for each transaction in a batch, I       could do something like:        create table TranBatches        (        BatchNr int identity(1,1),        CommonAttr whoknows        )       This common attribute might be transaction date. The transaction       table would have an FK into TranBatches.               What if there is no common attribute? Then, all I would have is       for TranBatches is a table of numbers. This strikes me as silly.               I suppose that I could roll my own with a table containing the       last batch number generated and add one to it in the stored procedure       I come up with for batch processing, but this strikes me as kludgy.               Is there an elegant way to generate batch numbers for the       transactions table, bearing in mind that a batch number will be used       for more than one row in the transactions table?              Sincerely,              Gene Wirchenko              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca