指定资料库回复到 data_time 指定时刻的资料状态(只对记录档还原有效)。
STOPATMARK = ‘mark‘ 指定还原操作进行到标记处。
STOPBEFOREMARK = ‘mark‘ 指定还原操作进行到标记之前。
通过OSQL命令执行SQL SERVER批SQL
通过System.Data.SqlClient命名空间只能执行单条SQL,或多个内容中间用;分开,不能执行类似等命令,有没有一种方法能类似查询分析器一样执行一些批命令呢,答案是通过OSQL来执行。
OSQL详细用法:http://technet.microsoft.com/zh-cn/library/ms162806.aspx
通地进程来调用:

C#代码
1 /// <summary>
2 /// 执行OSQL命令
3 /// </summary>
4 public static void ExcuteOsqlCmd(string cmd, string errorFile, string filePath)
5 {
6 System.Diagnostics.Process p = new System.Diagnostics.Process();
7
8 p.StartInfo.FileName = "osql";
9 p.StartInfo.Arguments = cmd;
10 p.StartInfo.UseShellExecute = false;
11
12 p.StartInfo.RedirectStandardError = true;
13 p.StartInfo.CreateNoWindow=true;
14 p.Start();
15 p.WaitForExit();
16 //p.Close();
17 int exitCode = p.ExitCode;
18 if (exitCode != 0)
19 {
20 StreamReader sr = new StreamReader(errorFile, System.Text.Encoding.Default);
21 string all = sr.ReadToEnd();
22 sr.Close();
23 //ExcuteOtherCmd(string.Format("notepad \"{0}\"", errorFile));
24 throw new StepException(all);
25 }
26 }
调用如下:
string comm = string.Format(" -U {5} -P {0} -S {1} -d {2} -b -e -i \"{3}\" -o \"{4}\"", pass,
conn.DataSource,
conn.Database,
FilePath, errorFile,user);
Process.ExcuteOsqlCmd(comm, errorFile, FilePath);//直接执行一个SQL文件,路径为FilePath
分享:
sqlcmd介绍
标签:ber sql gif key dir ring opened 哪些 输出