Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #85

Re: Getting a Batch Number

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver, microsoft.public.sqlserver.programming
Subject Re: Getting a Batch Number
Date Thu, 31 Mar 2011 23:46:18 +0200
Organization Erland Sommarskog
Lines 33
Message-ID <Xns9EB9F1D1AC66CYazorman@127.0.0.1> (permalink)
References <4ar9p6t864rknp0k2b6coc2ra684951c1l@4ax.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252
Content-Transfer-Encoding 8bit
Injection-Info mx01.eternal-september.org; posting-host="DD6dU+BfJNjsjSP4/K/V7w"; logging-data="1482"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18bEKEte2dy5N2uomtkutDn"
User-Agent Xnews/2006.08.24 Mime-proxy/2.1.c.0 (Win32)
Cancel-Lock sha1:bXhmp7mKXYEO88A+563aquCVgI4=
Xref x330-a1.tempe.blueboxinc.net comp.databases.ms-sqlserver:85

Cross-posted to 2 groups.

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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