just an example please update
INSERT INTO dbo.user (PersonID, Name, Age)
OUTPUT INSERTED.PersonID
SELECT s.PersonID, s.Name, s.Age
FROM stg_user s
WHERE NOT EXISTS (SELECT 1 FROM dbo.user u WHERE u.PersonID = s.PersonID)
This query will insert the rows from "stg_user" that are not already present in "dbo.user", and will also return the newly inserted "PersonID" values from "dbo.user". You can then use these values in subsequent queries or store them in a variable for further processing.