Create this in your database and grant permission to public.
--*********************
CREATE VIEW VFK AS
--Author: N.Raghavendra
--Created on: 7-Apr-2003
--Version: 1.0
SELECT
--Name of the FOREIGN KEY constraint
SO3.NAME FK_NAME,
--Unique ID of FOREIGN KEY constraint
SO3.ID FK_ID,
-- Owner of the table with the FOREIGN KEY constraint
SU.NAME TABLE_OWNER,
--Name of the table with the FOREIGN KEY constraint
SO.NAME TABLE_NAME,
--Object identification number.
SO.ID TABLE_ID,
--Name of the Column with the FOREIGN KEY constraint
SC.NAME COLUMN_NAME,
--Position of the column in the FOREIGN KEY constraint
SC.COLID COLID,
--Owner of the table referenced in the FOREIGN KEY constraint
SU2.NAME REF_TABLE_OWNER,
--Name of the table referenced in the FOREIGN KEY constraint
SO2.NAME REF_TABLE_NAME,
--Object identification number of the table referenced in the FOREIGN KEY constraint.
SO2.ID REF_TABLE_ID,
--Name of the column referenced in the FOREIGN KEY constraint
SC2.NAME REF_COLUMN_NAME,
--Position of the column in the reference column list
SC2.COLID REF_TABLE_COLID
FROM SYSFOREIGNKEYS SYSFK
--Foreign Key Constraint - Table info
INNER JOIN (SELECT UID, ID, NAME FROM SYSOBJECTS WHERE XTYPE = 'U') SO
ON SYSFK.FKEYID = SO.ID
--Referenced in the FOREIGN KEY constraint - Table info
INNER JOIN (SELECT UID, ID, NAME FROM SYSOBJECTS WHERE XTYPE = 'U') SO2
ON SYSFK.RKEYID = SO2.ID
--Foreign Key Constraint - Column info
INNER JOIN (select ID, COLID, NAME FROM SYSCOLUMNS) SC ON SYSFK.FKEYID =
SC.ID AND SYSFK.FKEY = SC.COLID
--Referenced in the FOREIGN KEY constraint - Column info
INNER JOIN (select ID, COLID, NAME FROM SYSCOLUMNS) SC2 ON SYSFK.RKEYID
= SC2.ID AND SYSFK.RKEY = SC2.COLID
--Name and ID of the FOREIGN KEY constraint
INNER JOIN (SELECT ID, NAME FROM SYSOBJECTS) SO3 ON SYSFK.CONSTID =
SO3.ID
--Foreign Key Constraint - Owner info
INNER JOIN SYSUSERS SU ON SO.UID = SU.UID
--Referenced in the FOREIGN KEY constraint - Owner info
INNER JOIN SYSUSERS SU2 ON SO2.UID = SU2.UID
GO
GRANT SELECT ON VFK TO PUBLIC
GO
--****************
Planet Source Boys and Gals, encourage
Brand New Young Talents
like me by rating/commenting/giving feedback/giving suggestions.
|