EXEC master..xp_cmdshell 'osql -Svaio -Usa -Pzaassds1 -ic:\MySQl.sql -n'
http://www.dotnet247.com/247reference/msgs/26/131475.aspx
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=561&lngWId=10
http://www.dotnet247.com/247reference/msgs/26/131475.aspx
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=561&lngWId=10
string szCurrentPath=System.IO.Directory.GetCurrentDirectory().ToString();
string szSQLFile=szCurrentPath+"\\test.sql";
string szFileName=@"C:\Program Files\Microsoft SQL Server\80\Tools\Binn\osql.exe";string szArguments="-S localhost -U sa -P -i"+szSQLFile;System.Diagnostics.ProcessStartInfo processStartInfo = new System.Diagnostics.ProcessStartInfo(szFileName,szArguments);
processStartInfo.UseShellExecute = false;
processStartInfo.CreateNoWindow = true;
processStartInfo.RedirectStandardOutput = true;
processStartInfo.RedirectStandardError = true;
System.Diagnostics.Process process = System.Diagnostics.Process.Start(processStartInfo);
Process1.StartInfo.FileName = "osql ";
Process1.StartInfo.Arguments = @" /E /S /n /i "+spname+".sql";
Process1.Start();
while (Process1.HasExited)
{
continue;
}
Process1.Close();