Insert INTO catalog_category_entity_varchar  (value_id,
entity_type_id,
attribute_id,
store_id,
entity_id,
value
) VALUES 
(NULL,
(  SELECT b.entity_type_id from eav_entity_type b
where  b.entity_table = 'catalog/product')
,
(
SELECT c.attribute_id from eav_entity_type b
JOIN eav_attribute c ON c.entity_type_id = b.entity_type_id
WHERE b.entity_table = 'catalog/product' and c.attribute_code = '<@ATTRIBNAME@>'
)

,<@PREFIX@>, <@KEY@>,
(
SELECT c.default_value from eav_entity_type b
JOIN eav_attribute c ON c.entity_type_id = b.entity_type_id
WHERE b.entity_table = 'catalog/product' and c.attribute_code = '<@ATTRIBNAME@>'
))
@@GO@@
update catalog_category_flat_store_<@PREFIX@> set 
value = '<@DEST@>' 
where entity_id = <@KEY@> and <@UPLIMAGES@> = 1
@@GO@@
