将一个大的格式文本(CSV)如何写入数据库?
小弟现有一个从别的部门导出的文本文件(CSV),有1.2GB   ,需要把它导入到SQLSERVER中(别人从ORACLE中导出),直接使用SQL的导入工具将直接死机(2GB)内存。 
 听别人说需要编一个程序,采用读入数据块的方法才能导入数据块。具体怎么实现呢?请各位大哥帮忙。
------解决方案--------------------帮顶到数据库区。
------解决方案--------------------如果是用VS2005的话,可以考虑用SqlBulkCopy类来实现,比直接操作数据库要快
------解决方案--------------------这是一个大文件存入数据库的问题,不能一次性的加入文件流并存入数据库,这样作的话,会占用大量的内存,可以参照控制BLOB的作法,这种方法,无论是1.1还是2.0都是可行的,上面说的SQLBulkCopy类在这里是不合适的,那个类只是用于数据库之间的转移,对于一个大文件存入数据库的最张解决方案就是“利用文件流进行分段控制”,具体作法就是:第一次先文件的一小部份,并将其插入数据库,然后再读一小部份,对刚才插入的那个字段进行更新(其实就是把新读的这个部份插入到第一次插入的那一小部份的后面),然后重复第二部。可以给你一个简单的代码: 
             OpenFileDialog of = new OpenFileDialog(); 
             of.ShowDialog(); 
             string file = of.FileName; 
             using (SqlConnection con = new SqlConnection( "server=.;database=test2;uid=sa;pwd=sa ")) 
             { 
                 con.Open(); 
                 byte[] ptr; 
                 using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read)) 
                 { 
                     byte[] buffer = new byte[1024]; 
                     int count = fs.Read(buffer, 0, 1024); 
                     //insert some data ,in that the image field will not be null 
                     using (SqlCommand cmd=con.CreateCommand ()) 
                     { 
                         cmd.CommandText =  "insert into blob (id,file2) values ( '1 ',@file2) "; 
                         SqlParameter sfile= cmd.Parameters.Add( "@file2 ",SqlDbType.Image ); 
                         sfile.Value = buffer; 
                         cmd.ExecuteNonQuery(); 
                     } 
                     using (SqlCommand cmd = con.CreateCommand()) 
                     { 
                         cmd.CommandText =  "select TEXTPTR(file2) from blob where id= '1 ' "; 
                         ptr = (byte[])cmd.ExecuteScalar(); 
                     } 
                     using (SqlCommand cmd = con.CreateCommand()) 
                     { 
                         cmd.CommandText =  "updatetext blob.file2 @ptr @offset null @data "; 
                         SqlParameter sptr = cmd.Parameters.Add( "@ptr ", SqlDbType.Binary, 16); 
                         SqlParameter soffset = cmd.Parameters.Add( "@offset ", SqlDbType.Int); 
                         SqlParameter sdata = cmd.Parameters.Add( "@data ", SqlDbType.Image );   
                         sptr.Value = ptr; 
                         soffset.Value = 0;                             
                         int index = 0; 
                         while (true) 
                         { 
                             count = fs.Read(buffer, 0, 1024 ); 
                             if (count==0) 
                             { 
                                 break; 
                             } 
                             if (count <1024) 
                             { 
                                 int i = 0; 
                             } 
                             sdata.Value = buffer; 
                             sdata.Size = count; 
                             cmd.ExecuteNonQuery(); 
                             index += count; 
                             soffset.Value = index;                               
                         }     
                     } 
                 } 
             }
------解决方案--------------------A Fast CSV Reader 
 By Sébastien Lorion