home bbs files messages ]

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,176 of 19,505   
   Erland Sommarskog to Gene Wirchenko   
   Re: Getting a Batch Number   
   31 Mar 11 23:46:18   
   
   XPost: microsoft.public.sqlserver.programming   
   From: esquel@sommarskog.se   
      
   Gene Wirchenko (genew@ocis.net) writes:   
   >      I now want to put together a simple database.  I thought that I   
   > would try something that modelled the way I do banking.  I can have   
   > multiple set-asides in one bank account.  I might write a cheque off   
   > one account that is to put money in more than one set-aside.  (Or I   
   > might transfer; it amounts to the same.)  For example:   
   >   
   >           cheque for $500 from Income account to Savings Account   
   > split:   
   >                Reserves $200, Income Tax Set-Aside $300.   
   >   
   >      This gives me a transaction batch of:   
   >   
   >           insert into Batches 'Sample Batch'   
   >            (with an id column value automatically generated)   
   >   
   >           insert into Transactions '20110331','Income',-500   
   >           insert into Transactions '20110331','Reserves',200   
   >           insert into Transactions '20110331','Income Tax S/A',200   
   >   
   >      How do I get the batch number from Batches to use in the   
   > Transactions inserts?   
      
   scope_identity()   
      
      
   --   
   Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se   
      
   Links for SQL Server Books Online:   
   SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx   
   SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx   
      
   --- 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