|
Posted by Ed Murphy on 05/24/07 16:10
Khafancoder wrote:
> in my db i have these three tables
>
> 1.Stores 2.Products 3.Parts
>
>
> their structure is something like :
>
>
> Stores ----> Products ----> Parts
>
>
> Stores
> ----------------
> StoreId, StoreName
>
>
> Products
> ----------------
> ProductId, StoreId, ProductName
>
>
> Parts
> ----------------
> PartId, ProductId, PartName
>
>
>
> now, in my application i wanna to implement a bulk-copy operation so
> user can copy products from one store to another one and when a
> product copied to new store;
>
> all of it's parts should copy too.
> in fact i need a method to insert a Product item in Products table and
> synchronously copy it's parts into Parts table and repeat this steps
> until all of proucts copied.
>
> how can i do that without cursors or loops ?
Why do you need to do that at all? It seems like you simply need
to do the following:
insert into Products n (ProductId, StoreId, ProductName)
select o.ProductId, @NewStoreId, o.ProductName
from Products o
where o.StoreId = @OldStoreId
Navigation:
[Reply to this message]
|