Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can indeed check the installed version, if you register your database as a data-tier application during deployment. You can do this by including the following in your publish profile:</p> <pre><code> &lt;RegisterDataTierApplication&gt;True&lt;/RegisterDataTierApplication&gt; </code></pre> <p>This option will register the schema and it's version number in the msdb database during deployment. Be sure to change the dacpac version number between releases! We use msbuild to create dacpacs, example code for setting the dacpac version:</p> <pre><code>DacVersion=$(ProjectReleaseNumber).$(ProjectBuildNumber).$(ProjectRevisionNumber) </code></pre> <p>Having done this, you can build version-aware predeployment scripts.</p> <pre><code>-- Get installed version, e.g. 2.3.12309.0 DECLARE @InstalledVersion NVARCHAR(64) = ( SELECT type_version FROM msdb.dbo.sysdac_instances WHERE instance_name = DB_NAME() ); -- Get the major part of the version number, e.g. 2 DECLARE @InstalledVersionMajor TINYINT = CONVERT(TINYINT, SUBSTRING(@InstalledVersion, 0, PATINDEX('%.%', @InstalledVersion))); IF (@InstalledVersionMajor &lt; 5) BEGIN; PRINT 'Do some nontrivial incremental change that only needs to be applied on version before 5'; END; </code></pre> <p>Checking for the version number that you are currently deploying is a little more cumbersome but can also be done. Check out Jamie Thomson's excellent blog for this technique:<a href="http://sqlblog.com/blogs/jamie_thomson/archive/2012/12/10/editing-sqlcmdvariable-nodes-in-ssdt-publish-profile-files-using-msbuild.aspx" rel="nofollow">Editing sqlcmdvariable nodes in SSDT Publish Profile files using msbuild</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload