i am getting the error as shown below :
Msg 156, Level 15, State 1, Procedure Sp_Table1, Line 22
Incorrect syntax near the keyword 'AS'.
while executing this SQL:
WITH myCTE AS
(Select mci.* from
view_name AS si
JOIN merch_catalog_ipt_view_name AS mci
ON mci.view_id = si.view_id
AND mci.resolved_view_name_id = si.view_name_id
AND mci.ctg_ipt_event_id = @ctg_ipt_event_id
AND mci.accept_flag = 'y')
UPDATE view_name
SET name = (select mci.name from myCTE where myCTE.view_id = view_id)
,view_name_ctg_id = (select mci.resolved_view_name_ctg_id from myCTE where myCTE.view_id = view_id)
,xref_value = (select mci.xref_value from myCTE where myCTE.view_id = view_id)
,availability_start_date = (select mci.availability_start_date from myCTE where myCTE.view_id = view_id)
,availability_end_date = (select mci.availability_end_date from myCTE where myCTE.view_id = view_id)
,status_code = (select mci.status_code from myCTE where myCTE.view_id = view_id)
,last_modified_user_id = (select CASE WHEN mci.last_modified_user_id = 42 THEN @posting_user_id ELSE mci.last_modified_user_id END from myCTE where myCTE.view_id = view_id)
,last_modified_timestamp = CURRENT_TIMESTAMP
WHERE si.shi_flag = 'n'
and exists (select view_id from merch_catalog_ipt_view_name AS mci
Where mci.view_id = view_name.view_id
AND mci.resolved_view_name_id = view_name.view_name_id
AND mci.ctg_ipt_event_id = @ctg_ipt_event_id
AND mci.accept_flag = 'y')
Please help