9

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 am not able to declare Id to be AUTO_INCREMENT.It showing some error.
Please suggest some solution.

Thanks in advance

Buzz
  • 6,030
  • 4
  • 33
  • 47
Linnet
  • 101
  • 1
  • 3
  • 8
  • Please Read all the comments carefully written over here...i thin it will be helpfull to you http://social.msdn.microsoft.com/Forums/en/transactsql/thread/8f67388b-5e34-46fc-b3db-686da32431d8 – Freelancer Sep 21 '12 at 11:55

2 Answers2

28

This depends on the variety of SQL you are using.

For SQL Server

 declare @input_data table (Id int NOT NULL identity(1,1), name varchar(50))
podiluska
  • 50,950
  • 7
  • 98
  • 104
8

From your syntax, I'm guessing you are using SQL Server. If so, use identity instead of auto_increment:

declare @input_data table (Id int primary key identity, ... )
Andomar
  • 232,371
  • 49
  • 380
  • 404