What is the difference between defining the PK as part of the table definition vs. adding it as a unique clustered index. Using the example below, both tables show up as index\_id 1 in sys.indexes, but only table1 has is\_primary\_key=1

I thought this was the same, but SSMS only shows the key-symbol on table1

Thanks.

```
CREATE DATABASE IndexVsHeap
GO
USE [IndexVsHeap]
GO

-- Clustered index table
CREATE TABLE [dbo].[Table1](
    [LogDate] [datetime2](7) NOT NULL,
    [Database_Name] [nvarchar](128) NOT NULL,
    [Cached_Size_MB] [decimal](10, 2) NULL,
    [Buffer_Pool_Percent] [decimal](5, 2) NULL
    CONSTRAINT [PK_LogDate_DatabaseName] PRIMARY KEY(LogDate, Database_Name) 
) 

-- Table as heap, PK-CI added later, or did i?
CREATE TABLE [dbo].[Table2](
    [LogDate] [datetime2](7) NOT NULL,
    [Database_Name] [nvarchar](128) NOT NULL,
    [Cached_Size_MB] [decimal](10, 2) NULL,
    [Buffer_Pool_Percent] [decimal](5, 2) NULL
) 

-- Adding PK-CI to table2
CREATE UNIQUE CLUSTERED INDEX [PK_LogDate_Database_Name] ON [dbo].[Table2]
(
    [LogDate] ASC,
    [Database_Name] ASC
) 
GO

SELECT object_name(object_id), * FROM sys.index_columns
    WHERE object_id IN ( object_id('table1'),  object_id('table2') )
SELECT * FROM sys.indexes
    WHERE name LIKE '%PK_LogDate%'

```