select b.name
from sys.tables a, sys.columns b
where a.name = 'EXTRACT_DIM_COURSE'
and a.object_id = b.object_id
INTERSECT
select b.name
from sys.tables a, sys.columns b
where a.name = 'EXTRACT_FCT_COURSE_GRADE'
and a.object_id = b.object_id
INTERSECT gives you the results that are part of both result sets. In this case the result was:
name
DATE_STAMP
DIM_DISTRICT_DISTRICT_ID
DIM_DISTRICT_SCHOOL_YEAR
DIM_SCHOOL_SCHOOL_ID
SCHOOL_YEAR
A more verbose but less readable way of getting the same result is by using a subselect in the where clause:
select b.name
from sys.tables a, sys.columns b
where a.name = 'EXTRACT_FCT_COURSE_GRADE'
and a.object_id = b.object_id
and b.name in (select b.name from sys.tables a, sys.columns b where a.name = 'EXTRACT_DIM_COURSE' and a.object_id = b.object_id)
No comments:
Post a Comment