我有状态组合列表:
Agents
Association
conf.delegate
Embassies
exhibitors
Ing-advert
Inquiry
Low Priority
Misc
PrioAdvert
Priority
Removes
Sec-Advert
Secondary
Service Provider
VIP
VIP Exhibitor
VIP Visitor
Visitors
我想要一种查询方式,
Misc
状态更改(更新)为Secondary/visitor/priority/Agents/Assciation/Inquiry/Exhibitors/Removes/Embassies/VIP/VIP exbitors/VIP visitors
但是Secondary/priority/visitor/Agents/Assciation/Inquiry/Exhibitors/Removes/Embassies/VIP/VIP exbitors/VIP visitor
不应更改为Misc
。
将Secondary
的状态更改为visitor/priority/Agents/Assciation/Inquiry/Exhibitors/Removes/Embassies/VIP/VIP exbitors/VIP visitors
但是visitor/priority/Agents/Assciation/Inquiry/Exhibitors/Removes/Embassies/VIP/VIP exbitors/VIP visitors
不应更改为Secondary
。
我在存储过程中编写了以下查询,该查询将状态更新为我想要的任何内容。
set
cmp.status=
case when
cmp.status='' OR
cmp.status IS NULL OR
cmp.status IS NOT NULL
then
dupl.status
else
cmp.status
end
from companyinfo cmp
inner join #DuplTempTable dupl on cmp.ID=dupl.ID
我不知道如何根据优先级编写更新查询。我知道我必须使用CASE WHEN
来实现它。
答案 0 :(得分:0)
尝试一下!
update cmp
set
cmp.status=
case when
cmp.status='' OR
cmp.status IS NULL OR
cmp.status IS NOT NULL
then
dupl.status
else
cmp.status
end
from companyinfo cmp
inner join #DuplTempTable dupl on cmp.ID=dupl.ID