CONVERT CỘT ẢO SANG CỘT THẬT
Update DuLieuKeToan set chuongTrinh = SoHopDong
from
(
select CASE WHEN MoreValue='' or CHARINDEX('>>>SoHopDong:',Morevalue,0)<=0 THEN N'' ELSE SUBSTRING(MoreValue+'>>>',charindex('>>>SoHopDong:',MoreValue,0)+LEN('>>>SoHopDong:'), charindex('>>>',MoreValue+'>>>',charindex('>>>SoHopDong:',MoreValue,0)+1)-charindex('>>>SoHopDong:',MoreValue,0)-LEN('>>>SoHopDong:')) END AS SoHopDong
,identityKey,ChuongTrinh
from dulieuketoan where nghiepvu in (1000003,1000004,1000005)
and MoreValue<>'' and MoreValue like '%sohopdong%'
)temp where temp.identityKey = DuLieuKeToan.identityKeyLast updated