select * into没有max rows限制T-SQL

时间:2017-10-31 14:12:31

标签: sql-server tsql

我在SQL中使用循环复制了一系列表。我从SQL Server Maximum rows that can be inserted in a single insert statment推断,对于我的SQL SERVER,使用select *可以插入的最大行数是10,000。但是,源表大于10,000行。有没有办法绕过这个限制而不明确说明select语句中的列,因为每个表都有不同的列?

DECLARE @iTable TABLE (TableName VARCHAR(50),Id int identity(1,1))
INSERT INTO @iTable
Select distinct table_name From INFORMATION_SCHEMA.COLUMNS 
Where table_name like 'D0%' OR table_name like 'D1%'
DECLARE @imax int
DECLARE @iSQL VARCHAR(MAX) 
DECLARE @iTableName VARCHAR(max)
DECLARE @iid int = 1
select @imax = MAX(Id) from @iTable
WHILE (@iid <= @imax) 
BEGIN
    SELECT @iTableName = TableName FROM @iTable WHERE Id = @iid
    SET @iSQL = 'select * into st_'+ @iTableName +' from '+ @iTableName +';'
    EXEC(@iSQL)
    SET @iid = @iid +1
END

1 个答案:

答案 0 :(得分:1)

如前所述,使用select into时行数没有限制。但是,您当然可以简化代码并摆脱该循环。

  if (@available(iOS 9.0, *)) {
  if ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft) {
      diff = diff * -1;
  }
}