I am trying to update a table from a select statement but none of my rows are being affected. If I run the select statement I get results so I am not sure . In the example I narrowed down the where clause. Any help will be appreciated.
My Select
select
a.Code,
a.ItemGroup,
a.Pack,
a.bar_code,
WHStockLink,WHUseInfoDefs,
b.[iBinLocationID],
c.cBinLocationDescription,
ucIIWBin1,
WHPackCode,
WHBarCode,
IdWhseStk
from
WhseStk b
join StkItem a on a.StockLink = WHStockLink
inner join _btblBINLocation c on c.idBinLocation = b.iBinLocationID
where
WHWhseID = 3 and
IdWhseStk = 1003000221089
order by WHStockLink
My Update
update WhseStk
set ucIIWBin1 = t1.cBinLocationDescription
from (
select
a.Code,
a.ItemGroup,
a.Pack,
a.bar_code,
WHStockLink,
WHUseInfoDefs,
b.[iBinLocationID],
c.cBinLocationDescription,
ucIIWBin1,
WHPackCode,
WHBarCode,
IdWhseStk
from
WhseStk b
join StkItem a on a.StockLink = WHStockLink
join _btblBINLocation c on c.idBinLocation = b.iBinLocationID
--where WHWhseID = 5 and c.idBinLocation = b.iBinLocationID
) t1
where WHWhseID = 5
If I tweak it every row gets affected with the same value .
What I am trying to to is actually to match using the stock link and Whse and populate 3 new user defined fields in the same table ie ucIIWBin1, ucIIWBin2, ucIIWBin13, which are the Bin Description (joined from another table) the barcode and pack from this table.
Whse:

Bin:

Stock:
