SQL Server 2005 和 SQL Server 2008 的兼容性问题

发布于 2024-10-26 15:19:50 字数 850 浏览 1 评论 0原文

我正在尝试在 SQL Server 计算机上执行架构文件。我目前安装了 SQL Server 2005 和 SQL Server 2008。当我尝试执行 .sql 文件(本应在 2008 版本上执行)时,出现以下错误。

Microsoft.SqlServer.Management.Common.ConnectionFailureException: 
Failed to connect to server . --->    
Microsoft.SqlServer.Management.Common.ConnectionFailureException: This SQL Server
version (10.0) is not supported

有没有办法指定 Microsoft.SqlServer.Management.Smo.dll 在执行程序时查看哪个版本或除了卸载 2005 版本之外的其他解决方法?

编辑

我正在从 ASP.Net 应用程序运行 .sql 文件并使用 Microsoft.SqlServer.SMO dll

ServerConnection conn = new ServerConnection(new System.Data.SqlClient.SqlConnection(connString),);
Server srv = new Server(conn);

// execute sql file
srv.ConnectionContext.StatementTimeout = 300000;
srv.Databases[conn.DatabaseName].ExecuteNonQuery(schema);

I'm trying to execute a schema file on a SQL Server machine. I currently have both SQL Server 2005 and SQL Server 2008 installed. When I try to execute the .sql file (meant to execute on the 2008 version) I get the following error.

Microsoft.SqlServer.Management.Common.ConnectionFailureException: 
Failed to connect to server . --->    
Microsoft.SqlServer.Management.Common.ConnectionFailureException: This SQL Server
version (10.0) is not supported

Is there a way to specify which version the Microsoft.SqlServer.Management.Smo.dll looks at when you execute the program or some other workaround other than uninstalling the 2005 version?

EDIT

I'm running the .sql file from an ASP.Net application and using the Microsoft.SqlServer.SMO dll

ServerConnection conn = new ServerConnection(new System.Data.SqlClient.SqlConnection(connString),);
Server srv = new Server(conn);

// execute sql file
srv.ConnectionContext.StatementTimeout = 300000;
srv.Databases[conn.DatabaseName].ExecuteNonQuery(schema);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

很快妥协 2024-11-02 15:19:50

根据您收到的错误消息,听起来很像您正在以某种方式使用/访问 SQL 2005 实用程序。 “版本 10.0”是 SQL 2008(工程术语,而不是营销术语)。您确定您正在访问正确的 dll 吗?

很久以前,我遇到过类似的事情。我们在一台机器上安装了 SQL 7.0 和 2000(我说过这是很久以前的事了),我们通过批处理文件、命令窗口等调用一些实用程序,而我们只能获取旧的/不兼容的要运行的实用程序的版本。几天后,有人 [Hi Greg!] 想要查看 DOS 环境的 PATH 设置,结果发现,由于文件夹列出的顺序,操作系统会在新版本之前找到旧版本。现在这样的事情可能会让你绊倒吗?

Based on the error message you're getting, it sounds very much like you are somehow using/accessing SQL 2005 utilities. "Version 10.0" is SQL 2008 (in engineering speak, as opposed to marketing). Are you sure you're accessing the right dll?

Once upon a time long ago, I hit something perhaps similar. We had SQL 7.0 and 2000 on one box (I said it was long ago) and we were calling some utility via batch file, Command window, something like that, and we could only get the old/incompatible version of the utility to run. Days later, someone [Hi Greg!] thought to look a the DOS environment PATH setting, and lo and behold, because of the order the folders were listed in, the OS would find the old version before the new one. Might something like this be tripping you up now?

过期情话 2024-11-02 15:19:50

从未尝试过从 ASP.NET 进程运行 SMO 内容,但您可能只需加载文件,按“GO”拆分并将其作为一系列 SQL 命令运行,而无需太多麻烦。这不应该关心 sql 版本问题,除非有一些 SQL 语句在某种程度上是特定于版本的。

Never tried to run SMO stuff from an ASP.NET process, but you can probably just load the file, split on "GO" and run it as a series of SQL commands without too much fuss. That should not care about the sql version issues unless there is some SQL statement that is somehow version specific.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文