![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
28/04/2011, 11:15
|
![Avatar de Libras](http://static.forosdelweb.com/customavatars/avatar147802_5.gif) | Colaborador | | Fecha de Ingreso: agosto-2006 Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 18 años, 5 meses Puntos: 774 | |
Respuesta: Como obtener el ID pk de una tabla dada SELECT @PrimaryKeyName =
COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE a
INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS b
ON a.CONSTRAINT_NAME = b.CONSTRAINT_NAME
WHERE a.table_name = @Tabla and constraint_type = 'Primary key'
Prueba con eso :)
Saludos!
__________________ What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me |