Advance Deployment Settings: Drop, Ignore & Exclude on USER not working - sql-server

We are using SSDT project in visual studio to manage my SqlServer deployments.
We create dacpac file and send it to our clients.
Then they update their DB using "Sql Server > Task > Upgrade Data-tier Application" option.
While doing this, we found it drop all the User which is not in dacpac but present in SqlServer DB. (though users are not droping - if we use SqlPackage.exe command line tool)
To prevent this DROP, we implement "Drop, Ignore & Exclude" setting in Advance Deployment Settings in SSDT project of Visual Studio.
But this seems not working.
Is I missing something?
How do i prevent USER from Drop?
SQL Server Version:
Microsoft SQL Server Management Studio 12.0.4213.0
Microsoft Data Access Components (MDAC) 6.3.9600.17415
Microsoft .NET Framework 4.0.30319.42000
Operating System 6.3.9600

Your best bet might be to package all of this up for the users with a Publish Profile set up to not drop users as well as a way they could easily use SQLPackage to do the changes. I know there's a NuGet package containing the DacFX now and Ed Elliott wrote up some stuff about using it in PowerShell here: https://the.agilesql.club/blogs/Ed-Elliott/DacFxed-Nugetized-DacFx-Powershell-Wrapper (see Solution 3)

If the customer is using an older version of DacFX, the "Ignore Users" etc. settings will be silently ignored.
Since you presumably don't control this, it might be an idea to package a current version along with your dacpac, and provide the customer with a deployment script.

Related

Not able to build Visual Studio Database Project targeting Azure SQL Database when using AT TIME ZONE

We have a Visual Studio Database Project that we are trying to move to Azure SQL Database. Some of our views use AT TIME ZONE which is supported in Azure SQL Database, but when I switch the database Target Platform to Microsoft Azure SQL Database in the project properties, it fails to build with error:
Error: SQL46010: Incorrect syntax near TIME.
I have connected directly to the database in Azure and I can use AT TIME ZONE, but I cannot create or publish a DACPAC file from my project.
This SO answer suggests switching the target to SQL Server 2016, but then you cannot deploy the DACPAC to Azure. It will give the error
A project which specifies SQL Server 2016 as the target platform cannot be published to Microsoft Azure SQL Database v12.
when publishing from Visual Studio or the command line with sqlpackage.exe. (Same with all targets).
This seems like a long-standing bug in Visual Studio Data Tools so others must have run into it. Does anyone have a workaround or suggestions?
I found the answer to this through another channel. This is a bug in Visual Studio 16.4 and the current preview of 16.5.
The Visual Studio 16.4 release removed support for Microsoft Azure SQL Database V11. In doing so, they removed the Project target for Microsoft Azure SQL Database V12, making the Microsoft Azure SQL Database the only option. The intention was for this new option to switch to targeting V12, but there is a bug and it still targets V11.
Until this is fixed in a future update of Visual Studio, the workaround is to manually edit the SQLPROJ file and change the line;
<DSP>Microsoft.Data.Tools.Schema.Sql.SqlAzureDatabaseSchemaProvider</DSP>
Adding in V12 to make it;
<DSP>Microsoft.Data.Tools.Schema.Sql.SqlAzureV12DatabaseSchemaProvider</DSP>
Save and reopen the solution. It now compiles and I can deploy to Azure.
This is the answer just to the second part of the question.
I had the same error while publishing .dacpac from free azure sql database to the one in basic plan.
A project which specifies SQL Server 2016 as the target platform cannot be published to Microsoft Azure SQL Database v12.
I figured that out by checking Allow incompatible platform in Advance setting of Publish Data-tier Application.

SQL Database Tools in Visual Studio 2012

I'm trying to setup my Visual Studio Project to be able to use only one IDE for managing SQL objects using TFS 2012. Is there any way to configure my project connected to a source control and if for example I go to SSMS and try to modify a stored procedure, automatically takes the one in the source control or vice versa using Visual Studio 2012 check out a procedure and from SSMS shows me that is checked out?
No matter where I'm (Management Studio or Visual Studio 2012)the SQL objects are synchronized.
Thanks
Microsoft doesn't provide any built-in support but you can link your SSDT database project to SSMS using the latest version of SQL Source Control, which is a commercial tool developed by Red Gate, the company I work for. Steps are:
Download SQL Source Control and install it (it has a 28-day free trial)
Load SSMS, right click on your database in the object explorer and select the Link to Source Control option.
In the Link dialog, browse to the database project folder in your repository.
That's it. It's now set up. Simply use the Commit and Get Latest tabs to keep your database in sync with your database project in source control.
I'd be happy to assist should you hit any problems. Please add a comment to this answer or contact support#red-gate.com

Setup and Deployement in VB.Net having Sql Server Database in the Project

I have completed my Project in VB.Net and has published my project.
But i want to come out of these things
I have Sql Server Database in my project and i want my setup to add that database to sql server on installing my project.
I want my application to automatically detect sql server 2008 r2 and if it is not instaled i want it to install for me and then atach the database.
I dont want to add the database as a Attached database in my project.
i dont want to install crystal report in my application.
I have some unused refernces in my application in my project which i want to removed, i have tried the default visual studio remove unused references but still have some references like shockwave.dll log2net.dll etc.
The first step would be to switch to an MSI-based installer. This should allow you to resolve issues 3 and 5 (you control what the MSI includes). You can use a Visual Studio setup project, WiX or a commercial setup authoring tool.
For installing your database (issue 1), the best approach depends on how you use your database. Some installers simply copy the database files, others install it using custom actions and others execute SQL scripts. You should first determine how you want to install it and then ask a more specific question if you encounter problems.
To install SQL Server when it's not found (issue 2), you can use a prerequisite. This is done differently for each setup tool, so you first need to decide on a tool and then research how it supports prerequisites.
For issue 4, I'm not sure I know what to say. An MSI package will install what you include in it. If you don't add Crystal Reports in your package, then it won't be installed.
Visit
http://www.codeproject.com/Articles/10032/Deploy-SQL-Server-databases-easily-with-an-Install
Deploy SQL Server databases easily with an Installer class
Best regards!
Elias Sant Anna

How to build a specialized installer in VS2010?

I'm looking to build a specialized msi installer, preferably with VS2010 to do the following:
Be able to configure SQL server connection.
Pick the database to be used from the SQl server.
Create database table with specified credentials.
Assign a new DB user a set of permissions.
Also configure the IIS application.
I looked into a default installer project in VS2010 and it has nothing related to dealing with SQL server and IIS. Any idea how can I do all this?
Visual Studio setup projects do not offer support for SQL scripts and IIS. The best you can do is write some custom actions (using custom code) to handle this during install.
Commercial setup authoring tools offer the most control over SQL scripts and IIS elements. You can find a list here: http://en.wikipedia.org/wiki/List_of_installation_software
You can also try WiX. It has a steep learning curve, but it's free and gets the job done.

Embedding SQL Server into a .NET application

Hey, I've just finished writing a VB.NET application. Now I want to package the executable and the database ofcourse into a single installer file. I tried using QSetup, InstallShield to make SQL Server embedded into the setup file, and finally after hours of try&fail I have no idea. Anyone?
You can do a rightmouse on the properties of your Visual Studio Setup Project, and then there is this button 'Prerequisites'. There you can tick 'SQL Server Express ...' Or the 'SQL Server Compact 3.5'
link to image
You're probably best off just to set the connection file directly to the mdf, and attach it when the program is run. This is easier as it doesn't require a custom setup script to install the database to the database directory itself.
Note: Consider using the Compact Version, it's smaller, people don't like a full blown engine on their computer :)
InstallShield has a concept called Setup Prerequisites where you can teach it how to install additional packages along with your own. In older versions this would happen before calling your MSI. In newer versions you can have a "Feature" prerequisite where the prereq can associated to a feature and only installed if that feature is selected to be installed and after it's been selected but still before the main activity of your MSI occurs during the install execute sequence.
InstallShield also has a pattern for executing SQL scripts against your database instance so that you can then load your database into your newly installed instance.
All of this is quite powerful but it does take a bit of digging to learn.
As far as I know, anything but the SQL Server Compact Edition (SQL Server CE) cannot be embedded into your setup, really. Microsoft doesn't want that - you need to have SQL Server Express installed separately - any other edition can't even be shipped with your software (the client must have a license and installation separately).
You can indeed distribute SQL server with your custom application:
http://msdn.microsoft.com/en-us/library/bb264562(SQL.90).aspx

Resources