Meghana M

Meghana M

  • 1.2k
  • 175
  • 23.6k

SQLquery:To check the condition & then insert the data if not existing

Dec 15 2023 1:57 PM

SQL query for the below scenario

eg: Employee table has 10 rows 

The TempEmployee table has 5 rows 

 TempEmp table should compare with the employee table and insert rows that are not present in the TempEmp

select emp.no, emp.name from dbo.Employee emp
          left join dbo.TempEmp temp on temp.no =emp.no 
               where emp.no is not null and ltrim(rtrim(emp.no)) 
            


Answers (2)