I am creating a stored procedure to insert data into a table from another table. However, all of the data that I want inserted into the new record is not in the other table and at the present time it is not in any table. I am calling this "static" data. I have two tables: one called Resident and one called Lease. If I have a record in the Lease table, I also want an associated record in the Resident table for that Lease.
These are the fields that I need to populate in the Resident table:
Comp_Name = SMITHJ1234
Comp_NameLong = SMITH; JOHN
Comp_Type = Resident
Comp_Status = Active
Comp_Source = Import
Comp_CreatedBy = 1
Comp_UpdatedBy = 1
These are the fields that will come from the Lease table:
Lease_primaryresident
Lease_name
So this is what I have right now for stored procedure:
INSERT INTO Resident (Comp_Name,Comp_NameLong)
SELECT Lease_primaryresident,
Lease_name
FROM Lease
WHERE NOT EXISTS (SELECT * FROM Resident
WHERE Lease.Lease_primaryresident = Resident.comp_name);
How do I get the other items to populate in the Resident record (i.e. comp_type, comp_status, etc.) during this insert?
Any assistance would be greatly appreciated.
Thanks!