SET NOCOUNT ON DECLARE @TbName varchar(50) SET @TbName ='tbl_Survey' DECLARE @ColName varchar(50) SET @ColName ='SurveyCode' DECLARE @TblID varchar(50),@ColuID varchar(50) SELECT @TblID = id FROM sysobjects WHERE [name] = @TbName SELECT @ColuID = colid FROM syscolumns WHERE id = @TblID AND [name] = @ColName SELECT B.Name as F_TblName, C.Name as F_ColName INTO #TmpTbl FROM SYS.sysforeignkeys as A,SYS.sysobjects as B, SYS.syscolumns as C WHERE A.rkeyid = @TblID And A.rkey = @ColuID And B.id = fkeyid And C.id = fkeyid And C.colid = fkey SELECT * FROM #TmpTbl DROP TABLE #TmpTbl SET NOCOUNT OFF[@more@]
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7192349/viewspace-1001738/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/7192349/viewspace-1001738/