0

是否可以在 sql 中以 12 组或批量存储数据?我有一个查询,在插入新行之前应该检查现有记录是否等于或小于十二。如果它们是 12 则它应该创建一个新批次,该批次也最多存储 12 条记录。

4

1 回答 1

0

There's no built-in concept of data batching in SQL Server, or any other SQL-like database out there. What you're describing is data grouping/relations, which is the responsibility of the database designer to figure out. What you should do is create a related table, called Batches. Give it a primary key. Then place that primary key column into your actual table with data as a foreign key. The logic about when batches are created should probably be defined in a trigger, or define the logic in a UDF and set the Default Value of that BatchId column to the result of that UDF.

于 2012-07-10T15:42:57.673 回答