You are here: Re: Synchronous Bulk-Copy into two table « MsSQL Server « IT news, forums, messages
Re: Synchronous Bulk-Copy into two table

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация