0

In SQL Server Management Studio, queries like this one:

SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME = [name_of_table];

can help find the name of the primary key, and I can easily find the name of the primary key in Object Explorer too, but I have yet to find way of identifying the table columns that uniquely determine the primary key. I have also consulted this particular answer, but "SHOW ..." within a query is always recognized as invalid on my end. Furthermore, the other queries suggested by that post were able to extract the name of my primary key (which I already have a means of obtaining as described at the beginning of this question), but I still don't know where to find the underlying columns that determine the primary key. Any ideas?

Community
  • 1
  • 1
Adam Freymiller
  • 1,929
  • 7
  • 27
  • 49
  • Any query involving "SHOW KEYS" is not recognized as valid within my version of SSMS. I typically use INFORMATION_SCHEMA to find out meta information about tables – Adam Freymiller Jul 11 '16 at 21:32
  • 1
    For SSMS, [this would appear to be a better duplicate](https://stackoverflow.com/questions/95967/how-do-you-list-the-primary-key-of-a-sql-server-table). – Ken Y-N Jul 12 '16 at 01:32

0 Answers0