I am going to rephrase your question and add in your comments so that others can follow along
I have 2 tables
Student and
TempStudent with identical schemas
CREATE TABLE dbo.Student (
ID int,
Name nvarchar(32),
Surname nvarchar(32)
) ON [PRIMARY]
How do I transfer the rows from the second table (TempStudent) into the first (Student) when the record does not exist?
Sample Data #1
Student table is empty, and TempStudent table has one row:
TRUNCATE TABLE Student;
INSERT TempStudent(ID, [Name], Surname)
VALUES (1, 'John', 'Alex)
I need the query to transfer this row
Sample Data #2
Student table should now have row#1 in it, and we have added a row to TempStudent
INSERT TempStudent(ID, [Name], Surname)
VALUES (2, 'Mary', 'Alex)
Again, I need the query to transfer this new row to Student, but only the new row
The solution is quite simple:
INSERT Student(ID, [Name], Surname)
SELECT ID, [Name], Surname
FROM TempStudent
WHERE ID NOT IN (SELECT ID FROM Student)