SQL Server 2008
使用所有正确的参考资料我敢说:
System.Data.SqlClient;
Microsoft.SqlServer.Management.Smo;
Microsoft.SqlServer.Management.Common;
Microsoft.SqlServer.Management.Sdk.Sfc;
Run Code Online (Sandbox Code Playgroud)
所有编译都没有错误.
为了便于调试,我已经将代码剥离到几乎为零.
连接到服务器等等.
执行以下代码:
SqlConnection connection = new SqlConnection(sqlConnectionString);
Server server = new Server(new ServerConnection(connection));
server.ConnectionContext.ExecuteNonQuery(sqlDBQuery);
Run Code Online (Sandbox Code Playgroud)
sqlDBQuery字符串在哪里:USE [master] GO ALTER DATABASE [Cassiopeia] SET ANSI_NULL_DEFAULT OFF GO ALTER DATABASE [Cassiopeia] SET ANSI_NULLS OFF GO
但是"sqlDBQuery"是什么并不重要,我总是得到同样的错误,比如
GO附近的语法不正确
.
我相信SMO会照顾这个,当我看到我ConnectionContext的时候就说BatchSeparator ="GO"
如果我删除GO它是一个去...可以这么说但我真的需要知道为什么我的SMO不起作用.
在任何地方,我看它只是说"像这样使用smo,你就没事了".嗯...对我不起作用.
请参阅Jon Galloway的这篇文章以供参考: http://weblogs.asp.net/jgalloway/archive/2006/11/07/Handling-_2200_GO_2200_-Separators-in-SQL-Scripts- 2D00 -the-easy-way.aspx
问候