I wrote this code trying to know the relations amongs other tables from my BD but it didn´t bring nothing.
Code
USE tuBaseDeDatos;Code
GO DECLARE @tabName AS Varchar(50)Code
SET @tabName = 'dbo.TU_TABLA'--table´s name from fk´s are goint to getCode
SELECT OBJECT_NAME(f.constid) AS 'FKName', c.name AS 'ColName'Code
FROM sysforeignkeys f INNER JOIN syscolumns cCode
ON f.fkeyid = c.id AND f.fkey = c.colidCode
WHERE fkeyid = OBJECT_ID(@tabName)
Laxmidhar SahooRank #383 · 6.6K reputationPosted Nov 8, 2018, 5:35 PM EST
Vincent Maverick DuranoRank #238 · 10.3K reputationPosted Nov 8, 2018, 11:28 AM EST
Sreekanth ReddyRank #726 · 3.2K reputationPosted Nov 8, 2018, 7:34 PM EST
Laxmidhar SahooRank #383 · 6.6K reputationPosted Nov 8, 2018, 8:48 PM EST
Ramon QuintanaRank #3,303 · 435 reputationPosted Nov 12, 2018, 3:14 AM EST
GO
/****** Object: StoredProcedure [dbo].[Ver_FK] Script Date: 12/11/2018 11:11:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[Ver_FK]
as
begin
exec sp_fkeys'dbo.VFS_AFV'
end
Ramon QuintanaRank #3,303 · 435 reputationPosted Nov 12, 2018, 3:22 AM EST
Ramon QuintanaRank #3,303 · 435 reputationPosted Nov 12, 2018, 3:29 AM EST
Sourav MukherjeeRank #850 · 2.6K reputationPosted Dec 6, 2018, 11:19 AM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts