How to copy a huge table data into another table in SQL Server

前端 未结 8 1283
慢半拍i
慢半拍i 2020-12-02 10:30

I have a table with 3.4 million rows. I want to copy this whole data into another table.

I am performing this task using the below query:

select * 
i         


        
8条回答
  •  时光说笑
    2020-12-02 11:15

    If you are copying into a new table, the quickest way is probably what you have in your question, unless your rows are very large.

    If your rows are very large, you may want to use the bulk insert functions in SQL Server. I think you can call them from C#.

    Or you can first download that data into a text file, then bulk-copy (bcp) it. This has the additional benefit of allowing you to ignore keys, indexes etc.

    Also try the Import/Export utility that comes with the SQL Management Studio; not sure whether it will be as fast as a straight bulk-copy, but it should allow you to skip the intermediate step of writing out as a flat file, and just copy directly table-to-table, which might be a bit faster than your SELECT INTO statement.

提交回复
热议问题