If the particular record can be identified by a simple condition, then use where:
update #test
set [status] = 'Missing'
where PID = 123 and Category = 'greatherthan8'
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
DROP TABLE if exists #test
create table #test
(
PID int,
Category varchar(100),
status varchar(10)
)
Insert into #test
values (123,'Lessthan8','compliant'),
(123,'greatherthan8','compliant'),
(456,'Lessthan8','Missing'),
(456,'greatherthan8','Missing'),
(789,'Lessthan8','compliant'),
(789,'greatherthan8','Missing'),
(999,'Lessthan8','Missing'),
(999,'greatherthan8','compliant'),
(11,'Lessthan8','Missing'),
(111,'greatherthan8','Missing'),
(22,'Lessthan8','compliant'),
(222,'greatherthan8','compliant')
--so outut should be
-- (123,'Lessthan8','compliant'),
-- (123,'greatherthan8','Missing')
Select * from #test
If the particular record can be identified by a simple condition, then use where:
update #test
set [status] = 'Missing'
where PID = 123 and Category = 'greatherthan8'
you haven't defined what identifies a unique row, so you may need all columns:
update #test
set status = 'new value'
where PID = 123 and Category = 'greatherthan8' and status = 'compliant'
note: this is poor table design. a table should have a unique key.