How to insert in a SQL server table a field that is not auto-incremented?

0

I have a table that has an "id" field but it is not defined as auto-incremented within the DB, there is a possibility that when inserting a record, it indicates that the "id" is going to be a self-incremented field using C #.

    
asked by Alberto Rojas 17.10.2016 в 19:27
source

1 answer

1

It should be calculated by obtaining the last value and then adding 1:

INSERT INTO Tabla
(Id, Valor)
VALUES((SELECT MAX(Id) + 1 FROM Tabla), 'Descripción del campo' )
    
answered by 17.10.2016 в 19:31