我需要将版本放在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读到的