当尝试将 6000 行插入临时表时,我收到以下消息
The number of row value expressions in the INSERT statement exceeds the maximum allowed number of 1000 row values.
源不在SQL Server
中。
CREATE TABLE #TMP_ISIN (
[Isin] nVARCHAR(250))
INSERT INTO #TMP_ISIN ([Isin])
VALUES
ABOUT 6000 ROWS
我该如何避免这个限制?
最佳答案
limit of 1000取决于 insert
的 values
子句中的行数,而不是临时表本身的限制:
The maximum number of rows that can be constructed by inserting rows directly in the VALUES list is 1000. Error 10738 is returned if the number of rows exceeds 1000 in that case.
To insert more than 1000 rows, use one of the following methods:
- Create multiple INSERT statements;
- Use a derived table;
- Bulk import the data by using the
bcp
utility or theBULK INSERT
statement.
因此,您可以使用较小的 insert
语句分块执行此操作。
insert into sometable (somecolumns) values <about 1000 rows>;
insert into sometable (somecolumns) values <about 1000 rows>;
:
insert into sometable (somecolumns) values <about 1000 rows>;
如果您需要所有 6000 个都是原子的,您可以围绕整个事物放置一个事务。
关于sql-server - 临时表 - 允许的最大行值数为 1000,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30319998/