Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-sqlserver > #85
| From | Erland Sommarskog <esquel@sommarskog.se> |
|---|---|
| Newsgroups | comp.databases.ms-sqlserver, microsoft.public.sqlserver.programming |
| Subject | Re: Getting a Batch Number |
| Date | 2011-03-31 23:46 +0200 |
| Organization | Erland Sommarskog |
| Message-ID | <Xns9EB9F1D1AC66CYazorman@127.0.0.1> (permalink) |
| References | <4ar9p6t864rknp0k2b6coc2ra684951c1l@4ax.com> |
Cross-posted to 2 groups.
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
Back to comp.databases.ms-sqlserver | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Getting a Batch Number Gene Wirchenko <genew@ocis.net> - 2011-03-31 14:19 -0700
Re: Getting a Batch Number Erland Sommarskog <esquel@sommarskog.se> - 2011-03-31 23:46 +0200
Re: Getting a Batch Number Gene Wirchenko <genew@ocis.net> - 2011-03-31 15:08 -0700
csiph-web