Ver Mensaje Individual
  #3 (permalink)  
Antiguo 28/04/2011, 11:15
Avatar de Libras
Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 17 años, 8 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