Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
trouble2
Constraint Violating Yak Guru
267 Posts |
Posted - 2010-09-07 : 10:29:51
|
Hi, I have a table with purchased products and each purchased product has a guarantee certificate.Now, in the new situation people can buy an extra certificate, so this means 1 purchased product can have multiple certificates attached to it.The table now looks like this (simplified):PurchasedItemsPurchasedItemID - ProductID - BuyerID - ProductPrice - CertificateID - CertificateStatus - CerificatePriceNow, I will add a new table called PurchasedItemsCertificates with the fields:PurchasedItemCertificateID - PurchasedItemID - CertificateID - CertificateStatus - CertificatePriceAnd I can alter the PurchasedItems table to:PurchasedItemID - ProductID - BuyerID - ProductPrice But is there some way you can make a script to copy the right information to the PurchasedItemsCertificate table?I don't have any experience with this... |
|
Kristen
Test
22859 Posts |
Posted - 2010-09-07 : 14:01:33
|
[code]INSERT INTO PurchasedItemsCertificates(PurchasedItemID, CertificateID, CertificateStatus, CertificatePrice)SELECT PurchasedItemID, CertificateID, CertificateStatus, CerificatePriceFROM PurchasedItemsWHERE CertificateID IS NOT NULL -- Assuming you only want items that HAVE a Certificate[/code] |
 |
|
|
|
|