
with cte as (
		select id,len(attributevalue) originalValLen,
			substring(attributevalue,0,sp-1) +
			'{"FieldId":690,"Value":"'+simnum+'","FieldValueForConfigFileCreation":"'+simnum+'"}'+
			substring(attributevalue,ep+1,len(attributevalue)) updatedJson
		from (
			select pa.id,pa.AttributeValue, 
				CHARINDEX('"FieldId":690,"Value":"',attributevalue) sp,
				CHARINDEX('}',attributevalue,CHARINDEX('"FieldId":690,"Value":"',attributevalue)) ep,
				c.SimNum
			from PanelAttributes pa
				join cptbl c on c.cpid=pa.PanelId and c.Deleted is null and simnum!='' and simnum is not null
			where attributekey like 'AdditionalAttributes'
				and AttributeValue like '%FieldId":690,%'
			) z

)
update p
set p.attributevalue=cte.updatedJson
from PanelAttributes p
	join cte on cte.Id=p.id
