问题一
如何高效快速的把excel 中的数据导入到数据库(sqlserver)中?
要代码插入,不是sqlserver自带的导入方法
(execl数据可能有50000多)
问题二

分页存储过程有实例没有?速度应该比假分也快?
求助一份····问题三
数据库中如何按某几个字段或者说某列去掉重复数据问题四
如何实现数据库中两个表进行数据替换
如A表  为主表
  B表  为附表
把B表的数据替换
他们的字段或者说列名都是相同的  

B表中  c字段  b字段   的内容 
与A表中的 c字段 b字段 的内容    
相同那么我们就把 B表中的 dd字段的内容换成 A表中的 dd字段的内容请问有没存储过程可以快速的实现???因为有时候可能要替换好几万条数据

解决方案 »

  1.   

    先回答下第一个问题吧,这个我也遇到过,用如下的代码就能解决大量数据上传的问题,我试过,大概6万行数据用了20秒左右。下面是代码的大概内容,具体你自己分析一下写出来吧,或者你把你的数据库的字段和excel的字段发出来,我替你写下也行。
     INSERT INTO TBL_Demand(
    Part_No, MasterProduct, Parent_Type, BOM, Master_Factory, EMS_factory,
    num_col1, num_col2, num_col3, num_col4, num_col5, num_col6, num_col7, num_col8, num_col9, num_col10,
    num_col11, num_col12, num_col13, num_col14, num_col15, num_col16, num_col17, num_col18
    )
    --下面是从excel中来的
    SELECT PartNo, MasterProduct, [Parent Type], BOM, [Master Fastory], [EMS factory],
    wk35, wk36, wk37, wk38, wk39, wk40, wk41, wk42, wk43, 
    [y201011], [y201012], [y201101], [y201102], [y201103], [y201104], [y201105], [y201106], [y201107]
    FROM opendatasource('Microsoft.Jet.OLEDB.4.0',
    'Data Source="D:\T\FCST_1.xls";User ID=;Password=;Extended properties=Excel 5.0')...[t1$]
    where PartNo is not nullexec sp_configure 'Ad Hoc Distributed Queries',0
    reconfigure
    exec sp_configure 'show advanced options',0
    reconfigure 
      

  2.   

    针对第一个问题:/// <summary>
            /// 根据excel表格返回一个DataSet
            /// </summary>
            /// <param name="Path"></param>
            /// <returns></returns>
            public DataSet ExcelToDS(string Path)
            {
                string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Path + ";" + "Extended Properties=Excel 8.0;";
                OleDbConnection conn = new OleDbConnection(strConn);
                conn.Open();
                string strExcel = "";
                OleDbDataAdapter myCommand = null;
                DataSet ds = null;
                strExcel = "select * from [sheet1$]";
                myCommand = new OleDbDataAdapter(strExcel, strConn);
                ds = new DataSet();
                myCommand.Fill(ds, "table1");
                conn.Close();
                return ds;
            }有这个数据集 接下来怎么做随你了
    Excel 8.0 表示为excel2003格式的表格,要是2007写法有区别的
      

  3.   

    问题二
    分页存储过程有实例没有?速度应该比假分也快?
    求助一份····
    回答这个吧
    其实就是
    declare @pageSize int
    declare @pageIndex int
    select top @pageSize ID,name from tableA where ID not in (select top @pageSize*(@pageIndex-1) ID from tableA order by ID desc) order by ID desc
    真分页和加分页的最直接区别是:真分页每次只查询所要显示的那些数据,查询速度快,加分页则是首次加载全部查询,如果数据量很大,首次加载的时候速度会很慢,使用分页存储过程将这个速度大大缩小,每次查询数据少,页面加载自然也就加快
      

  4.   

    记录用户操作日志,aajx 轮询用户是否在线
    单独登录记录状态
    分页存储过程搜索很多
    在SQL SERVER导入EXCEL
    分sheet,sqlbulkcopy导入数据