简体   繁体   English

无法从SQL Server 2005中的现有表中的新表中插入记录

[英]can't insert records in new table from existing table in sql server 2005

I need to insert records into a new table from an existing table. 我需要将记录从现有表插入到新表中。 I used the following query to do this: 我使用以下查询执行此操作:

Insert into Newtable
Select * from Oldtable where date1 = @date

This query works most of the time, but in one scenario I get 10 million records to be inserted for the date1 value. 此查询在大多数时间都有效,但是在一种情况下,我将插入1000万条记录以作为date1值。 In this case I'm getting the following error message: 在这种情况下,我收到以下错误消息:

Error : The transaction log for database "tempDB" is full. 错误:数据库“ tempDB”的事务日志已满。 To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases 要找出为什么无法重用日志中的空间的原因,请参阅sys.databases中的log_reuse_wait_desc列

Should I break the query into parts and insert them sequentially, or is there a way to do this with the current query? 我应该将查询分为多个部分并按顺序插入,还是可以对当前查询执行此操作?

This is, perhaps, a distasteful suggestion. 这也许是一个令人反感的建议。 But, you can try exporting the data to a file and then inserting using bulk-insert, with database logging set to SIMPLE or BULK-LOGGED. 但是,您可以尝试将数据导出到文件,然后使用批量插入将数据库日志记录设置为SIMPLE或BULK-LOGGED进行插入。

More information is at http://msdn.microsoft.com/en-us/library/ms190422.aspx . 有关更多信息,请访问http://msdn.microsoft.com/zh-cn/library/ms190422.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM