I am using Microsoft SQL Server 2005
I have two tables, lets say TableA
, and TableB
CREATE TABLE TableA (
A_ItemNumber (int)
A_IsDeleted (bit)
)
CREATE TABLE TableB (
B_ItemNumber (int)
B_OrderNumber (varchar)
)
INSERT INTO TableB VALUES
(1, 'XY004005'),
(2, 'XY005125'),
(3, 'XY499999'),
(4, 'XY511340')
I need to write an update query that does the following:
Gets the
B_ItemNumber
for ALLB_OrderNumbers
where the int part of the string < 500000 (XY004005
would be included since004005 < 500000
, butXY511340
would not)Use this item number to
UPDATE A_IsDeleted WHERE A_ItemNumber = B_ItemNumber
I basically want to change A_IsDeleted
to TRUE for all A_ItemNumber = B_ItemNumber where B_OrderNumber < XY500000
I thought this could be a simple join/update but it doesn't look like that is allowed.