Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Joining SysObjects and other tables...
Message
 
 
À
21/05/2002 08:36:57
Eudoxio Junior
Hospital Sao Marcos
Teresina, Brésil
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00659293
Message ID:
00659305
Vues:
20
>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--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform