我tOrder
在 SQL Server 2008 中有一个具有以下结构的表 ( )
orderID (int) - this is currently the primary key and the identity field.
name(varchar)
address(varchar)
groupID (int) - now this field i need to also auto increment, but at the same time i want to be able to insert values into.
我的数据看起来像:
1 - john - address1 - 1
2 - mary - address2 - 1
3 - mary -address3 - 2
4 - jane - address4 - 3
其中订单 ID 1 和 2 共享同一个 group ,而 3 和 4 属于他们自己的。
许多订单可以有相同groupID
的,但是当我插入一个新组的订单时,我希望groupID
自动填充下一个序列号,同时允许我在groupID
需要时为不同的订单插入重复的订单。
希望这是有道理的。
我该怎么做呢?(我在后端使用 c#,如果这有什么不同的话)