> For the complete documentation index, see [llms.txt](https://kythuat.dtechvn.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kythuat.dtechvn.com/du-lieu-ke-toan/convert-cot-ao-sang-cot-that.md).

# CONVERT CỘT ẢO SANG CỘT THẬT

Chuyển cột 'sohopdong' từ cột ảo sang cột thật 'chuongtrinh'

```sql
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.identityKey
```
