I have a temp table variable with a bunch of columns:
Declare @GearTemp table
(
ItemNumber varchar(20),
VendorNumber varchar(6),
ItemStatus varchar(20),
Style varchar(20),
ItemName varchar(100),
ItemDescription varchar(1000),
Color varchar(50),
[Size] varchar(50),
ItemCost decimal(9,4),
IsQuickShipFl bit,
IsEmbroiderable bit,
IsBackOrderable bit,
LoadDate smalldatetime
)
It gets filled with data from another table via an insert statement, and I want to take that data and update my Products table. If possible, I would like to do something like this:
Update Products blah blah blah all columns where itemnumbers match up
SELECT * FROM @GearTemp FT
WHERE EXISTS (SELECT P.ItemNumber FROM Products P WHERE FT.ItemNumber = P.ItemNumber)
Is that possible to do? If it’s not, please point me in the right direction.
If I understand you correctly, you can use something like this:
Note that this will only work if, as you stated in the comments above, there is only ever one entry in
@GearTempfor eachItemNumber.