又没有类似的例子?

解决方案 »

  1.   

    //读取    StreamReader sr = new StreamReader(@"d:\**.sql");
                string strsql =  sr.ReadToEnd();
      执行在连接数据库后 sqlcmd.CommandText = strsql;执行就可以了
      

  2.   

    StreamReader sr = new StreamReader(@"d:\**.sql");
    string strsql =  sr.ReadToEnd();strsql做为sql语句执行一下就行了
      

  3.   

    this solution won't work if the script contains go statement.start a new process call osql to run the script
      

  4.   

    osql 实用工具
    osql 实用工具使您得以输入 Transact-SQL 语句、系统过程和脚本文件。该实用工具通过 ODBC 与服务器通讯。语法
    osql
        [-?] |
        [-L] |
        [
            {
                {-U login_id [-P password]}
                | -E
            }
            [-S server_name[\instance_name]] [-H wksta_name] [-d db_name]
            [-l time_out] [-t time_out] [-h headers]
            [-s col_separator] [-w column_width] [-a packet_size]
            [-e] [-I] [-D data_source_name]
            [-c cmd_end] [-q "query"] [-Q "query"]
            [-n] [-m error_level] [-r {0 | 1}]
            [-i input_file] [-o output_file] [-p]
            [-b] [-u] [-R] [-O]
        ]sql内置工具,.sql文件中可以今有[go]之类的非sql标准语句,适合在安装程序调用
      

  5.   

    楼上的兄弟 请问怎么调用osql ?谢谢
      

  6.   

    Process p=new Process();
    p.StartupInfo.FileName="osql.exe";.
    .
    .p.Start();