How to add SQL Server primary key?

Asked

Viewed 647 times

0

Good morning! maybe it is simple my doubt, but... I would like to know how to add primary key in a table not being at the time of creation (CREATE), I know that when accessing the table in "Object explorer" in the option "design" is easily possible with two click’s... but I would really like to know how to do via code. Thank you in advance.

1 answer

1


Run the following table change code.

ALTER TABLE NOME_DA_TABELA ADD PRIMARY KEY (NOME_DO_CAMPO)
  • great, what I needed... thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.