How to Auto-populate SQLCMD variable with Build/Assembly Version - sql-server

Using Visual Studio 2013 with TFS and SQL Server 2012 & 2014, and SQLPackage.exe with a Publish profile.
Does anyone know if/how to get the Build version or Assembly version into a SQLCMD variable?
i.e. I'm trying to obtain whatever system-level build versioning information TFS/Visual Studio has about an SQL project build and push this into a SQLCMD variable and then insert that into a table.
I know that I can explicitly define an SQLCMD variable and then manually set and increment the value of it, but I want whatever build version number has for the project.
I've been able to get the Assembly version info via MSBuild, as detailed here: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/e0c93a55-d8bd-4a32-89d9-f46013fc1235/automatic-version-increment-on-datatier-applications?forum=ssdt
But that is outside of my post-deploy.sql script. I've tried simply referencing the $(IntermediateTargetAssembly) variable, but the project won't build and errors that this variable not been declared.

I realize this is a different deployment setup than you are currently using but I think you will find it may work out better overall.
http://dotnetcatch.com/2016/02/10/deploying-a-database-project-with-msdeploy/
You could set the build version on your MSDeploy package using the MSBuild property you found via MSDeploy Parameterization to update a SQL script that would insert or update the source version in your database.

Related

How to keep track of the previous version number in MSI WIX

I'm trying to add a functionality of upgrading my SQL database using one single upgradeScripts.sql file in which I need to hardcode the previous build version and before running the upgrade scripts I need to check If the upgradeScripts.previous build number matches the LocalDB.build number. If don’t match then don’t execute the upgrade scripts.
So how can I hardcode the previous build number in WIX itself?
I prefer to create a table in the database itself and use that. It's all too easy to backup/restore a database and install/uninstall/reinstall/upgrade who knows what version for the MSI version to matter. What's important is that the current MSI being installed can create a net new database and migrate a previous schema to the current version. I do this for simple databases that need to be installed on clients silently.
Alternatively, for servers/more complex database, I like to move this out of the installer and into the application. For example Azure DevOps server does this with an Admin Tool. This way your developers have all of their favortite tools available to them without struggling with WiX and MSI.
Not sure you can do it via wix, but you can store build number in registry and use custom actions to check it:
Add custom action
In that custom action try to read value from registry
If there's some, run your script with values. you can do it from custom action too, or modify script and run it via sql script
After successful installation add new version to registry. You can do it via CA with OnExit="success" - it will run only on successful installation. Here's example with cancel, just change it to success. Or just add custom action after your scrit run. It's easier.

RCU.bat File Not Executing During Install of ODI 12.2.1.4

When installing Oracle Data Integrator (ODI) 12.2.1.4.0 on a Windows 10 machine, the Studio installation is successful, however the rcu.bat script does not run and the repositories cannot be created.
Upon double-clicking on the icon here is no window to proceed upon execution of the RCU batch file, and no error message is displayed.
I have tried to execute the rcu.bat file from cmd as administrator as well but facing an error like below:
The syntax of the command is incorrect.
p.s: There is an link in oracle support as well but could not see the update from there since I do not possess an Oracle Support Identifier.
link: https://support.oracle.com/knowledge/Middleware/2627367_1.html
I am using Java 1.8, created java_home in system environment variables as well,
Screenshot of Environment Variables also edited the Path Variables.
Before ODI installation, installed Oracle Database 12c in Windows10 Machine.Oracle DB is running smooth but is there any thing related to DB installation or Oracle Path which I missed.
This is a known bug with ODI 12.2.1.4 and will be fixed in the next release.
A workaround is to execute rcu_internal.bat located in the same folder.

Edit Project.Params outside visual studio data tools SSIS

Hi is there a way to edit the package.params file in a SSIS solution without visual studio?
I have a feeling that what you're wanting to do is set a new value for the package parameters at runtime. You can set these in the package store or in the execution settings, http://www.sqlchick.com/entries/2015/1/4/parameterizing-connections-and-values-at-runtime-using-ssis-environment-variables .
I found out that there are no external applications needed you can do it through environment variables and SSMS You can read the full article here
How to configure SSIS 2012 project to run under different environment configurations?

Overriding DefaultDataPath and DefaultLogPath variables when using SqlPackage to publishing a dacpac

The environment:
Using a SQL Server Database Tool in Visual Studio 2013, Update 4 to create a DacPac for publishing a database.
Using TFS build to build and drop the database project.
Using SqlPackage version to publish the dacpac to SQL Server 2012.
Using the SqlPackage Action "Publish", the script for deployment is generated using the following variables based on the target database's defaults:
:setvar DefaultDataPath "H:\YourServerDefault"
:setvar DefaultLogPath "H:\YourServerDefault"
I would like to override these locations to land in a specific pair of directories where we have some external encryption configured.
I have attempted to override these SQLCMD values in a couple ways:
Override on the command line:
SQLPackage /Action:Publish /SourceFile:./Db.dacpac /Profile:./MyProfile.publish.xml /Variables:DefaultDataPath=H:\MyNewLocation
Add an override in the publish profile (snippet below):
<ItemGroup>
<SqlCmdVariable Include="DefaultDataPath ">
<Value>H:\YourServerDefault</Value>
</SqlCmdVariable>
</ItemGroup>
While I can use either technique to override my own defined SQLCMD variables, the built in ones like DefaultDataPath and DefaultLogPath are ignored.
Is there a way to override these values when publishing with SqlPackage?
There is no built in support in SqlPackage but you can do this using a deployment contributor. Take a look at the DbLocationModifier sample on GitHub that solves exactly this issue. To actually use this, you need to:
Download the code from Github
Add a signing key to the project
Install to the correct extensions directory, or put it in the same folder as SqlPackage itself.
Pass additional arguments to SqlPackage specifying your contributor name and arguments - see the test code for how to do this via the API, the SqlPackage calls are essentially the same.
For more information about contributors and how to use them you can read the tutorial I wrote or read the walkthroughs on MSDN.
Disclosure: I work on the SQL Server tools team.

TFS - Compare branch and export

We currently use TFS 2010 for our VS applications and our SQL code. For SQL we have every stored procedure stored in different text files e.g."spname.sql" and we alter these files and then apply them to the Dev server.
When it comes to testing we then do a branchcompare to compare the DEV branch to the UAT branch to get a list of the .sql files that are different.
Question is, is there a way to export out the files in the list from the dev branch so we can them apply all the SQL code that has changed to the UAT server?
(We do table alters / updates etc in a "rollout" type script).
Thanks
When you do a compare in Visual Studio (with SSDT), you can choose to create a script instead of deploying. Or you could use powershell Get-TfsItemHistory with -Version to get the file list and then use that list to get the source.

Resources