declare @customexport table
(
--first table school_table
schlid char(10),
schlschool char(10),
schldegyr char(4),
--second table school_table (this is where I get stuck)
schlid char(6)
schlschool char(10),
schldegyr char(4)
--third table bio table
spouseID char(10),
)
insert into @customexport
(schlid,schlschool,schldegyr,?????)
select schlid,schlschool,schldegyr,?????
from school_table
left outer join school_table ??
on schlid=schlid
The question is how do I declare and insert data into multiple instances of the same table. In this case I want to get the primary persons school and another instance of the same table to get the spouse school. Essentially if the spouseID is equal to the second instance of the school then I want to include it
(
--first table school_table
schlid char(10),
schlschool char(10),
schldegyr char(4),
--second table school_table (this is where I get stuck)
schlid char(6)
schlschool char(10),
schldegyr char(4)
--third table bio table
spouseID char(10),
)
insert into @customexport
(schlid,schlschool,schldegyr,?????)
select schlid,schlschool,schldegyr,?????
from school_table
left outer join school_table ??
on schlid=schlid
The question is how do I declare and insert data into multiple instances of the same table. In this case I want to get the primary persons school and another instance of the same table to get the spouse school. Essentially if the spouseID is equal to the second instance of the school then I want to include it