Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to exclude objects/object types from sqlpackage?

I would like to exclude certain object, for example all logins & users, from extract or publish operation of sqlpackage.exe.

This is possible from within Visual Studio, so I hope it is also possible from the sqlpackage.exe.

Or is it not possible?

The reason is that I would like to be able to auto-deploy to various environments/servers, where the logins & users are different.

NOTE: Logins & Users is only an example, the question is more general.

like image 864
SAS Avatar asked Jan 24 '14 11:01

SAS


4 Answers

It is now. Please update the tools and look at this post.

http://blogs.msdn.com/b/ssdt/archive/2015/02/23/new-advanced-publish-options-to-specify-object-types-to-exclude-or-not-drop.aspx

like image 150
Derek Smalls Avatar answered Nov 11 '22 01:11

Derek Smalls


I solved this problem by creating a DeploymentPlanModifier contributor (following their SchemaBasedFilter sample) that I pass-in through in an argument (/p:AdditionalDeploymentContributors) for SQLPackage.exe, it looks for any drop operations of security object types.

(Code on Prevent dropping of users when publishing a DACPAC using SqlPackage.exe)

like image 45
DanStory Avatar answered Nov 11 '22 00:11

DanStory


Your best bet at this point is to look at doing this in post-deploy scripts and excluding all logins/users from your projects. We have similar issues where each environment has a different set of logins/users and SSDT just does not handle this well out of the box. I've written about the process we use on my blog (borrowed heavily from Jamie Thomson).

http://schottsql.blogspot.com/2013/05/ssdt-setting-different-permissions-per.html

I'll also note that the user "pavelz" left a comment briefly describing the process they use w/ composite projects - main project for objects and sub-projects for permissions. That could work as well.

The only issue we have run into with the post-deploy process is if you enable publishing to drop permissions/logins not in the project, you could have some down time until you re-add the permissions at the end. Once set, I highly recommend turning off those options.

like image 4
Peter Schott Avatar answered Nov 11 '22 00:11

Peter Schott


Sadly, as of now sqlpackage.exe utility does not have any option of excluding a specific object. However, it does have options to exclude an entire object type.

like image 2
shilpa Avatar answered Nov 11 '22 01:11

shilpa