Hi all :)

Currently now I used MS SQL Server Management Studio 2008.

I have an existing table with data already store on that table.
Table Name :
Application

Column :
Categories (nvarchar(1), null)
Sequence (nvarchar(1), null)
Detail (nvarchar(150), null)

I would like to ask how to add primary key to column Categories and Sequence ?

Thank you in advance !

in Oracle you'd do something like
CREATE UNIQUE INDEX "MYSCHEMA"."MYTABLE_PK" ON "MYSCHEMA"."MYTABLE" ("CATEGORIES", "SEQUENCE")

Of course you could never use the name "SEQUENCE" for a column in Oracle as it's a reserved word (as it is in MS SQL Server, I'm kinda surprised it let you create a column with that name...).

ALTER TABLE Persons
ADD CONSTRAINT pk_PersonID PRIMARY KEY (P_Id,LastName)

I have tried but get an error "Cannot define PRIMARY KEY constraint on nullable column in table Application" in SQL Server 2018

commented: Don't hijack old discussions that can't possible apply. 2016 above and you are asking about 2018. Make a new discussion. -3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.