>Hi,
>I'm trying to join sysobjects and syscolumns to find tables whose have a certain field (id_patient) as foreign key. I did it but some tables are triggered and when I try to change id_patient to a new value SQL Server returns an error saying that a subquery returns more than one result and that I'm trying to use some comparison operator. So i thought to join all the triggered tables with the sysobjects and find their primary keys to change each one at time. How can i do this? How can i put a string (the result of field 'name' in the sysobjects table) in a join statement?
>Wait for any help... Thanks...
MS doesn't recomend to access system table directly because there structure could change between versions. In Sql Server 2000 you can use INFORMATION_SCHEMA Views. Here's the sample query based on pubs DB.
SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc
JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu
ON tc.CONSTRAINT_name = ccu.CONSTRAINT_name
WHERE CONSTRAINT_type = 'FOREIGN KEY'
And COLUMN_name = 'title_id'
--sb--