sql-server - 临时表 - 允许的最大行值数为 1000

标签 sql-server limit temporary

当尝试将 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取决于 insertvalues 子句中的行数,而不是临时表本身的限制:

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 the BULK 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/

相关文章:

java - 临时变量的效率(例如java)

c++ - *临时*排序 vector 的好方法是什么?

sql-server - 如何在没有日志的情况下删除SQL表中的大数据?

tcp - 我是使用 1 个端口进行 1000 个连接,还是使用 1000 个端口,每个端口有 1 个连接?

临时对象的 C++ 调用函数

email - CentOs 邮件服务器限制每 30 分钟

parse-platform - 使用 Parse.com 发送推送通知的内部/外部查询的限制?

sql - 从表中抓取一行

SQL 语句 - 如何通过索引提高速度

c# - 如何在 ASP.NET 应用程序运行的整个过程中保持 SqlConnection 处于打开状态?