How to declare an auto increment variable in a virtual table of a stored procedure

I have a stored procedure like this

create procedure onedata as begin declare @input_data table (Id int NOT NULL AUTO_INCREMENT, name varchar(500) . .... ) insert into @input_data ..... .... end 

But I can not declare Id AUTO_INCREMENT . It shows some error.
Please suggest some solution.

Thank you in advance

+4
source share
2 answers

It depends on the variety of SQL used.

For SQL Server

  declare @input_data table (Id int NOT NULL identity(1,1), name varchar(50)) 
+11
source

From your syntax, I assume that you are using SQL Server. If so, use identity instead of auto_increment :

 declare @input_data table (Id int primary key identity, ... ) 
+4
source

Source: https://habr.com/ru/post/1435488/


All Articles