M
M
Max Trophy2016-04-16 12:59:19
SQL Server
Max Trophy, 2016-04-16 12:59:19

How to add a populated field to a finished sql table?

There is a table from one field, already filled. How to add an ID field to it with a key, an identifier that will automatically fill in to those lines that have already been entered, and, of course, automatically filled in when new brands are added?
MARK | ID
--------------------
Nissan | 1
subaru | 2
Toyota | 3
Tried via alter table marki add id int not null primary key
This adds a field but the values ​​of already existing rows are null

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2016-04-16
@kapitoly

alter table marki add id int not null identity(1,1) primary key

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question