Insert would not work in my case. Because there may be possibility that data may be present in Emp2 table.Hence i would like to carry on with update.Any new answer please.
I tried your query but it is not working for me. This query does not overwrite the existing value in emp2 but it adds additional records. I want something which would overwrite the records.
MERGE dbo.Emp2 AS tgt
USING dbo.Emp AS src ON src.EmpID = tgt.EmpID
WHEN NOT MATCHED BY TARGET
THEN INSERT (
EmpID
)
VALUES (
src.EmpID
)
WHEN MATCHED
THEN UPDATE
SET tgt.Col1 = src.Col1;