8

我有一个这样的存储过程

create procedure onedata

as

begin

declare @input_data table (Id int NOT NULL AUTO_INCREMENT, name varchar(500) . .... )

insert into @input_data .....
....

end

但我无法将 Id 声明为AUTO_INCREMENT。它显示了一些错误。
请提出一些解决方案。

提前致谢

4

2 回答 2

27

这取决于您使用的 SQL 的种类。

对于 SQL 服务器

 declare @input_data table (Id int NOT NULL identity(1,1), name varchar(50))
于 2012-09-21T11:51:57.010 回答
8

根据您的语法,我猜您正在使用 SQL Server。如果是这样,请使用identity而不是auto_increment

declare @input_data table (Id int primary key identity, ... )
于 2012-09-21T11:52:11.487 回答