这个自增字段,怎么写?
CREATE TABLE [ProductCartons] (
[ProductID] [int] NOT NULL ,
[Carton#] [int] not null,
[CLength] [float] NULL DEFAULT (0),
[CWidth] [float] NULL DEFAULT (0),
[CHeight] [float] NULL DEFAULT (0))
GO
--ID 为1的第一个Carton,[Carton#]自增为1
insert ProductCartons([ProductID],[CLength],[CWidth],[CHeight])
values(1,18,15,19)
--ID 为1的第二个Carton,[Carton#]自增为2
insert ProductCartons([ProductID],[CLength],[CWidth],[CHeight])
values(1,36,30,38)
怎么把[Carton#]设为自增字段
如果插入新的ProductID,[Carton#]为1
如果插入的ProductID已存在,[Carton#]=该ProductID的最大[Carton#]+1
高手帮忙,谢谢!!!