저는 Microsoft SQL 서버에 익숙하지 않고 데이터베이스에별로 관심이 없습니다.
다음과 같은 의심이 있습니다.
내 데이터베이스에는 CPE 라는 테이블이 있습니다.
이 테이블에는 내 테이블 의 FOREIGN KEY 인 SourceId 라는 필드 (열) 가 있습니다.
따라서이 필드는 2 개의 테이블을 함께 묶기 때문에 다른 테이블의 일부 필드에 정의 된 값을 포함해야한다고 생각합니다.)
다른 필드와 연결된 다른 테이블이 무엇인지 알아 내려면 어떻게해야합니까?
Tnx
안드레아
당신은 확실히 찾고 있습니다 :
sp_help [table_name]
또는 다음 쿼리를 시도하십시오.
select t.name as ForeignKeytable, fk.constraint_column_id as ForeignKey_No, c.name as ForeignKeyColumn
from sys.foreign_key_columns as fk
inner join sys.tables as t on fk.parent_object_id = t.object_id
inner join sys.columns as c on fk.parent_object_id = c.object_id and fk.parent_column_id = c.column_id
where fk.referenced_object_id = (select object_id from sys.tables where name = 'name')
order by ForeignKeytable, ForeignKey_No
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다