How to create a user for a login in 2013 SQL Server Database Project

后端 未结 2 1199
半阙折子戏
半阙折子戏 2021-02-05 09:59

I\'m trying to create a user with a login for a SSDT database project. The login already exists on the target server. With the following SQL:

CREATE USER [MyLogi         


        
2条回答
  •  忘了有多久
    2021-02-05 10:23

    If you are guaranteed to have the login on the server, your best bet is to tweak your master dacpac file. There are some instructions on how to do this here: http://sqlproj.com/index.php/2013/02/how-to-add-objects-to-master-dacpac

    Alternatively, you could remove references to logins from the SSDT portion and handle it in post-deploy scripts. If you have any sort of environment where different permissions need to be applied in different server (Development, QA, Production), that might be the better option. I've blogged about this here: http://schottsql.blogspot.com/2013/05/ssdt-setting-different-permissions-per.html

    Hopefully one of those will help. I've actually used the first option to work around an issue with needing to use EXECUTE AS, which requires that the user is in the project. It was a little tricky to get the exact XML, but I worked around it by creating an empty project with just that login, building it, and copying the XML from the dacpac into the master dacpac.

提交回复
热议问题