What this does is basically expand the data you have in the existing FRUITS
table. Re-reading your original post, I see that you want the stuff in a
new table, FRUITFLAT. So what I'd do is insert everything from FRUIT into
FRUITFLAT and then run my code against FRUITFLAT.
Now, to answer your latest question, I need a bit more info. Is FRUIT
static or are you updating it and want the changes reflected in FRUITFLAT?
If so, that can be managed via a trigger on FRUIT. The FRUITFLAT table
would have to exist before you place the trigger on FRUIT.
--
Tom
----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
[quoted text, click to view] "Ernie" <esersen@harris.com> wrote in message
news:1179492079.639127.248960@n59g2000hsh.googlegroups.com...
On May 17, 6:36 pm, "Tom Moreau" <t...@dont.spam.me.cips.ca> wrote:
> Something like:
>
> while exists (select * from FRUIT where QTY > 1)
> begin
> begin tran
> insert FRUIT (ITEM, CODE, QTY)
> select
> ITEM, CODE, 1
> from
> FRUIT
> where
> QTY > 1
>
> update FRUIT
> set
> QTY = QTY - 1
> where
> QTY > 1
> commit tran
> end
>
> --
> Tom
>
> ----------------------------------------------------
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
> SQL Server MVP
> Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
>
> "Ernie" <eser...@harris.com> wrote in message
>
> news:1179439913.536164.99830@l77g2000hsb.googlegroups.com...
> I have a MSSQLSERVER2000 table 'FRUIT' with the following data
>
> ITEM CODE QTY
> Apple 101 2
> Banana 102 1
> Orange 103 3
>
> What I need is to create a MSSQLSERVER2000 table 'FRUITFLAT' that
> looks like this:
>
> ITEM CODE QTY
> Apple 101 1
> Apple 101 1
> Banana 102 1
> Orange 103 1
> Orange 103 1
> Orange 103 1
>
> Can I do this with a Stored Procedure or does it need to be done with
> VB (For/Next)? I am using MSACCESS2003 as a front-end for the
> database.
>
> Either way, could you provide [specific and detailed] code that allows
> me to do this.
>
> Thanks.
>
> Ernie
Thanks, Tom!
Is this code that I would use in an Update or Append or MakeTable
Stored Procedure?
Ernie