Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting PKs of Tables
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00755682
Message ID:
00755699
Vues:
22
This message has been marked as the solution to the initial question of the thread.
Mark,

Try
SELECT * FROM   INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc
	JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu 
		ON tc.CONSTRAINT_name = ccu.CONSTRAINT_name 
	WHERE CONSTRAINT_type = 'PRIMARY KEY' 
>In Oracle, the following SQL will return a cursor of tables and what columns are indexed as the Primary Key for each table. What SQL will return the same for SQL Server? TIA!
>select
>  B.Constraint_Type,
>  A.Index_Name,
>  A.Table_Name,
>  A.Column_Name
> from
>  User_Constraints B, User_Ind_Columns A
> where A.Index_Name = B.Constraint_Name
>   and B.ConstraintType = 'P'
> order by A.Table_Name
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform