I am new to sql server. i was trying to learn creating index. i tried to create a table with below query:
CREATE TABLE [Ref].[Country](
[CountryId] [uniqueidentifier] NOT NULL,
[CountryName] [varchar](50) NOT NULL,
[CreatedDate] [datetime2](2) NOT NULL,
[ModifiedDate] [datetime2](2) NULL,
CONSTRAINT [UCI_CountryName] UNIQUE CLUSTERED ([CountryName] ASC),
CONSTRAINT [PK_Country] PRIMARY KEY ([CountryId])
)
The non clustered index got created automatically on primary key. Now, i want to create NCI on Primary key column with INCLUDE. I did create it with below query:
CREATE UNIQUE NONCLUSTERED INDEX [NCI_CountryId] ON [Ref].[Country]
(
[CountryId] ASC
)
INCLUDE ([CountryName])
As you can see in below image, there is two NCI on same column that is CountryId, one is created by default while creating a table(PK_Country) and another which i created with INCLUDE using above query(NCI_CountryId).
I do not want two NCI's on same column, need only NCI created with INCLUDE. Is there a way to create NCI with include on PK at time of creating table ?
I'm working on sql server on Azure VM.