Hi ,
i am facing this issue from last 3 days actually the below query fulfilled my requrirement but this code is rejected by lead and asked to make it as merge statement.
my actual query is
Step-1
insertinto [dbo].[cmscpt_new]([Code],[Description],[InputOn]
, [InputBy] ,[CptReview],[AddedbyApplication],[Status])
select [code],[description],getdate(),'101','n','VAN','Active'
FROM [dbo].[cpt_load_2013]
whereisnull(current_update_indicator,'A')<>'D' andisnull(Modifier,'00')='00'
and [code] notin(select codefrom [CMSCpt_new])
and [description] not in(select [description]from [CMSCpt_new])
Step-2
update a
set a.[description]= b.[description]
from [cmscpt_new] a, [cpt_load_2013] b
where a.[Code]=b.[Code]
Purpose of the above query is:
1. if code is not exist in cmscpt_new table then i need to insert code from cpt_load_2013 table if code is exist then i need to update descritpion from cpt_load_2013 to cmscpt_new table based on code .
thanks in advance
sai