Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Basic Update Question

$
0
0

Dear Group,

I have two tables in two different R2 databases. We will call them Table1 and Table2 for convenience. I would like to update records in Table2 from the values of rows in Table1. I would like to loop through Table1 and find the corresponding record in Table2 and update the fields Table2.PriceChangeDate (datetime) – ‘2014-04-01 00:00:00.000’ and Table2.PriceChange (float) with the value of the Table1.Price (float).

So to me it would be:

Update Table2.PriceChangeDate = ‘2014-04-01 00:00:00.000’ AND Table2.PriceChange  = Table1.Price

WHERE

Table2.ProductID  = Table1.ProductID AND Table2.PriceLevelID = Table1.PriceLevelID  AND Table2.TimeBand = Table2.TimeBand

The table structure is:

[Database1].[Table1]:

ID (nvarchar(15)) - Identity

ProductID (nvarchar(15))

PriceLevelID (nvarchar(15))

TimeBand (nvarchar(15))

Price (float)

[Database2].[Table2]:

ID (nvarchar(15)) - Identity

ProductID (nvarchar(15))

PriceLevelID (nvarchar(15))

TimeBand (nvarchar(15))

PriceChangeDate (datetime)

PriceChange (float)

Thanks very much for your help. It will be easy for the group I am sure but it has me slightly confused.

Alastair (from UK)


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>