データベース・ユーザーの追加、削除、ユーザーのログイン・パスワードの変更、データベースの追加、分離

1675 ワード

osql.ExceはSQL Serverが提供するツールで、このツールを利用してデータベースユーザーを追加、削除し、ユーザーのログインパスワードを変更し、データベースを追加、分離することができます.プログラムによるデータベース管理に役立ちます.
public  void  ExecuteSqlFile(string strFileName)

     {  Process   SqlProcess=new  Process();   

        SqlProcess.StartInfo.FileName="osql.exe";   

        SqlProcess.StartInfo.Arguments="-U sa -P sa123 -d  mydb -i"+ strFileName;

      SqlProcess.StartInfo.WindowStyle=

        ProcessWindowStyle.Hidden;   

        SqlProcess.Start(); 

        SqlProcess.WaitForExit();   

        SqlProcess.Close();  }

構文sqlcmd[{−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][−c][−c][−c][−q][−q][−q][−c][−q][−q][−q]]query」[-Q"query"[-m error_level][-V][-W][-u][-r[0|1][-i input_file][ -o output_file ] [ -f < codepage > | i: < codepage > [ < , o: < codepage > ] [ -k [ 1 | 2 ] ] [ -y display_width ] [-Y display_width ] [ -p [ 1 ] ] [ -R ] [ -b ] [ -v ] [ -A ] [ -X [ 1 ] ] [ -x ] [ -? ] ]