In my sql statement:
SELECT DISTINCT C.TABLE_NAME,C.CONSTRAINT_NAME,C.COLUMN_NAME
FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE C
INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS T
ON T.TABLE_NAME = C.TABLE_NAME
WHERE C.TABLE_NAME = 'VALOR_CAMPO_DATA'
AND C.COLUMN_NAME IN ('ID','REV')
AND T.CONSTRAINT_TYPE = 'FOREIGN KEY';
I would like to return only FK's, but PK's are also coming. I have specified in where T.CONSTRAINT_TYPE = 'FOREIGN KEY'
, but it is not working, if I only execute INFORMATION_SCHEMA.TABLE_CONSTRAINTS
it works,
Does anyone know how I solve this problem?