sql-server – 如何版本SQL Server数据库?

我需要将版本放在sql Server 2005数据库上,并可以从.NET应用程序访问这些版本.我在想的是在数据库中使用扩展属性,名称为’version’,当然值将是数据库的版本.我可以使用sql来获得这个.我的问题是这听起来像一个好的计划,还是有更好的方法添加一个sql Server数据库的版本?

假设我无法使用表来保存元数据.

解决方法

我这样做:

创建一个模式表:

CREATE TABLE [dbo].[SchemaVersion](
    [Major] [int] NOT NULL,[Minor] [int] NOT NULL,[Build] [int] NOT NULL,[Revision] [int] NOT NULL,[Applied] [datetime] NOT NULL,[Comment] [text] NULL)

更新架构:

INSERT INTO SchemaVersion(Major,Minor,Build,Revision,Applied,Comment)
VALUES (1,9,1,getdate(),'Add Table to track pay status')

获取数据库模式版本:

SELECT TOP 1 Major,Build from SchemaVersion
ORDER BY Major DESC,Minor DESC,Build DESC,Revision DESC

改编自我在Coding Horror读到的

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...