I am getting these errors while executing the following SQL please help me
;WITH myCTE AS
(Select mcisi.* from
coke_packaged_item AS spi
JOIN coke_item AS si
ON si.coke_id = spi.coke_id
AND si.coke_item_id = spi.coke_item_id
AND si.shipper_flag = 'n'
JOIN merch_cat_import_coke_item AS mcisi
ON mcisi.coke_id = si.coke_id
AND mcisi.resolved_coke_item_id = si.coke_item_id
AND mcisi.cat_import_event_id = @cat_import_event_id
AND mcisi.accept_flag = 'y')
UPDATE coke_packaged_item
SET packaged_in_uom_id = (select resolved_packaged_unit_of_measure_id from myCTE where myCTE.coke_id = coke_id)
priced_in_uom_id = COALESCE((select resolved_weight_unit_of_measure_idfrom myCTE.coke_id = coke_id), @each_uom_id),
name = (select packaged_item_name from myCTE where myCTE.coke_id = coke_id),
package_weight = (select package_weight from myCTE where myCTE.coke_id = coke_id) ,
status_code = (select status_code from myCTE where myCTE.coke_id = coke_id) ,
last_modified_user_id = (select CASE WHEN last_modified_user_id = 42 THEN @posting_user_id ELSE last_modified_user_id END from myCTE where myCTE.coke_id = coke_id),
last_modified_timestamp = CURRENT_TIMESTAMP
and exists (select coke_id from coke_item AS si
where si.coke_id = spi.coke_id
AND si.coke_item_id = spi.coke_item_id
AND si.shipper_flag = 'n')
and exists (select coke_id from merch_cat_import_coke_item AS mcisi)
where mcisi.coke_id = si.coke_id
AND mcisi.resolved_coke_item_id = si.coke_item_id
AND mcisi.cat_import_event_id = @cat_import_event_id
AND mcisi.accept_flag = 'y'
The error message is:
Msg 102, Level 15, State 1, Procedure Sp_Name, Line 44
Incorrect syntax near 'priced_in_uom_id'.
Msg 102, Level 15, State 1, Procedure Sp_Name, Line 44
Incorrect syntax near '.'.
Msg 102, Level 15, State 1, Procedure Sp_Name, Line 45
Incorrect syntax near ','.
Msg 102, Level 15, State 1, Procedure Sp_Name, Line 46
Incorrect syntax near ','.
Msg 102, Level 15, State 1, Procedure Sp_Name, Line 47
Incorrect syntax near ','.
Msg 102, Level 15, State 1, Procedure Sp_Name, Line 48
Incorrect syntax near ','.
Msg 156, Level 15, State 1, Procedure Sp_Name, Line 54
Incorrect syntax near the keyword 'and'.
Msg 156, Level 15, State 1, Procedure Sp_Name, Line 55
Incorrect syntax near the keyword 'where'.