Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 script for finding related tables in svr2000 error

Author  Topic 

alejo46
Posting Yak Master

157 Posts

Posted - 2012-02-14 : 13:57:41
Good afternoon, i've got a script that prints out related tables with their correspondent foreign keys, it works fine in sqlserver 2008 but in in sqlserver 2000 is not working. yielding the error:

Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'sys.sysforeignkeys'.
Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'sys.syscolumns'.
i need that this script work fine in 2000, how do i find a similar one that works fine en sqlserver 2000?
Id appreciate your help
this is the script:
Select
object_name(rkeyid) Parent_Table,
object_name(fkeyid) Child_Table,
object_name(constid) FKey_Name,
c1.name FKey_Col,
c2.name Ref_KeyCol
From
sys.sysforeignkeys s
Inner join sys.syscolumns c1
on ( s.fkeyid = c1.id And s.fkey = c1.colid )
Inner join syscolumns c2
on ( s.rkeyid = c2.id And s.rkey = c2.colid )
Order by Parent_Table,Child_Table



visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-14 : 14:02:50
thats because sql 2000 does not have catalog views

just try replacing them with syscolumns and sysforeignkeys instead

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -