如何找到 SQL Server 数据层应用程序的当前版本?

编程入门 行业动态 更新时间:2024-10-11 07:35:27
本文介绍了如何找到 SQL Server 数据层应用程序的当前版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用 SQL Server 数据层应用程序(dacpac 或 DAC 包),我很难找到数据库的当前版本.

We are using a SQL Server Data-tier application (dacpac or DAC pack) and I'm having a hard time finding the current version of the database.

有没有办法使用这些方法获取当前版本:

Is there a way to obtain the current version using any of these methods:

在 SQL Server Management Studio 中通过 SQL 语句以编程方式使用 .NET 代码

推荐答案

从 SQL Server Management Studio 内部

来自 http://msdn.microsoft/en-us/library/ee210574.aspx

查看部署到数据库引擎实例的 DAC 的详细信息:

To view the details of a DAC deployed to an instance of the Database Engine:

选择查看/对象资源管理器菜单.

Object Explorer 窗格连接到实例.

Connect to the instance of the from the Object Explorer pane.

选择查看/对象资源管理器详细信息菜单.

Object Explorer 中选择映射到实例的服务器节点,然后导航到 ManagementData-tier Applications 节点.

Select the server node in Object Explorer that maps to the instance, and then navigate to the ManagementData-tier Applications node.

详细信息页面顶部窗格中的列表视图列出了部署到数据库引擎实例的每个 DAC.选择一个 DAC 以在页面底部的详细信息窗格中显示信息.

The list view in the top pane of the details page lists each DAC deployed to the instance of the Database Engine. Select a DAC to display the information in the detail pane at the bottom of the page.

Data-tier Applications 节点的右键菜单也用于部署新的 DAC 或删除现有的 DAC.

The right-click menu of the Data-tier Applications node is also used to deploy a new DAC or delete an existing DAC.

SELECT instance_name, type_version FROM msdb.dbo.sysdac_instances

通过 Azure 上的 SQL 语句

SELECT instance_name, type_version FROM master.dbo.sysdac_instances

以编程方式使用 .NET 代码

请注意,在 DacFx 3.0 中这不再有效.请参阅我的其他答案以了解如何做到这一点.

Programmatically using .NET code

Note that in DacFx 3.0 this is no longer valid. See my other answer for a way to do it.

ServerConnection serverConnection;
string databaseName;

// Establish a connection to the SQL Server instance.
using (SqlConnection sqlConnection =
    new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
{
    serverConnection = new ServerConnection(sqlConnection);
    serverConnection.Connect();

    // Assumes default database in connection string is the database we are trying to query.
    databaseName = sqlConnection.Database;
}

// Get the DAC info.
DacStore dacstore = new DacStore(serverConnection);
var dacInstance = dacstore.DacInstances[databaseName];
System.Diagnostics.Debug.Print("Database {0} has Dac pack version {1}.", databaseName, dacInstance.Type.Version);

VB.NET

Dim serverConnection As ServerConnection
Dim databaseName As String

' Establish a connection to the SQL Server instance.
Using sqlConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("DefaultConnection").ConnectionString)
    serverConnection = New ServerConnection(sqlConnection)
    serverConnection.Connect()

    ' Assumes default database in connection string is the database we are trying to query.
    databaseName = sqlConnection.Database
End Using

' Get the DAC info.
Dim dacstore As New DacStore(serverConnection)
Dim dacInstance = dacstore.DacInstances(databaseName)
System.Diagnostics.Debug.Print("Database {0} has Dac pack version {1}.", databaseName, dacInstance.Type.Version)

这篇关于如何找到 SQL Server 数据层应用程序的当前版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-03-19 00:33:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/625742.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   版本   数据   SQL   Server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!