我一个表,两列。当一列的值为c01时,另一列的值全部改为0
------解决思路----------------------
用update直接更新 或者
select ... case ... when 计算列
------解决思路----------------------
if exists (select top 1 1 from A where col1=1)
begin
update A with(rowlock) set col2=0
end
------解决思路----------------------
UPDATE 表
SET 另一列=0
WHERE 一列='C01'
是这个意思?
------解决思路----------------------
不是很清楚你的需求意思,给你两个版本
if exists (select top 1 1 from A where col1=‘c01’)
begin
update A with(rowlock) set col2=0 where col1=‘c01’
end
版本二
if exists (select top 1 1 from A where col1=‘c01’)
begin
update A with(rowlock) set col2=0
end