临时表-允许的最大1000行值数 [英] Temporary Table - Maximum allowed number of 1000 row values

查看:562
本文介绍了临时表-允许的最大1000行值数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在临时表中插入6000行时,出现以下消息

When trying to insert 6000 rows into a temp table I get the following message

INSERT语句中的行值表达式的数量超过了 最大允许的1000个行值的数量.

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

如何避免此限制?

推荐答案

限制的数量insertvalues子句中的行数,而不是临时表本身的限制:

The limit of 1000 is on the number of rows in the values clause of the insert rather than a limitation of the temporary table itself:

通过直接在VALUES列表中插入行可以构造的最大行数为1000.如果在这种情况下行数超过1000,则会返回错误10738.

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.

要插入1000行以上,请使用以下方法之一:

To insert more than 1000 rows, use one of the following methods:

  • 创建多个INSERT语句;
  • 使用派生表;
  • 使用bcp实用程序或BULK INSERT语句批量导入数据.
  • Create multiple INSERT statements;
  • Use a derived table;
  • Bulk import the data by using the bcp utility or the BULK INSERT statement.

因此,您可以使用较小的insert语句以块的形式进行操作.

Hence you can do it in chunks, with smaller insert statements.

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个原子原子,则可以对整个事务进行事务处理.

If you need all 6000 to be atomic, you can put a transaction around the whole thing.

这篇关于临时表-允许的最大1000行值数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆