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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 bulk insert

Author  Topic 

raindear
Yak Posting Veteran

64 Posts

Posted - 2013-12-04 : 09:33:20
Hi

I have two tables joined by one common value Variant ID

In table2 I have a field called SalePrice

In table1 I have the following fields

ExtendedPriceID,ExtendedPriceGUID,VariantID,CustomerLevelID,Price,ExtensionData,CreatedOn,UpdatedOn

The table is currently empty but the ExtendedPriceGUID is created automatically.

How I can i insert rows that will create a row for any product in table2 that has a SalePrice and then use that as the Price value in table 1?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-04 : 09:49:34
what all columns doestable2 have? does it have all other columns required by table1 like ExtendedPriceID,CustomerLevelID,ExtensionData,CreatedOn,UpdatedOn etc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

raindear
Yak Posting Veteran

64 Posts

Posted - 2013-12-04 : 10:08:54
The only unique identifier that appears in both tables in VariantID
Go to Top of Page

raindear
Yak Posting Veteran

64 Posts

Posted - 2013-12-04 : 10:30:43
Full set is

Variant ID, VariantGUID, IsDefault, Name, Description, SEkeywords, SEdecription, Colors, ColorSKUModify, Sizes, SizeSKUModify, FroogleDescription,ProductID, SKUSuffix,ManufacturePartNumber,Price,SalePrice,Weight,MRSP,Cost,Points,CreatedOn,UpdatedOn
Go to Top of Page

raindear
Yak Posting Veteran

64 Posts

Posted - 2013-12-04 : 12:31:07
So I need to join the two tables and then insert the Price as the sale price?
Go to Top of Page

badlydressedboy
Starting Member

4 Posts

Posted - 2013-12-05 : 00:53:35
Variant ID is a foreign key in table 1 - pointing at what looks like the primary key in table 2.
Insert new rows into table 1 and include the variant ID that points at the desired/existing price row in table 2.

---------------------------------------------------------------------------------------------------------------------
Performance Tuning & Monitoring Software: www.minidba.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-05 : 01:33:36
quote:
Originally posted by raindear

So I need to join the two tables and then insert the Price as the sale price?


what about other columns?
where will you get the value for them?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -