Ms VS2017 with SSDT has the ‘User with Password’ template but thinks it’s wrong

Posted on

Question :

In my database project when I choose the ‘User with Password’ template in the Add New Item dialog, code is generated, kind of

CREATE USER [u2]
    WITH PASSWORD = 'jbniq_ushfbwc=l5nAxu8aapmsFT7_&#$!~<Jt}ho_aypip@'

GO

GRANT CONNECT TO [u2]

And it’s immediately marked as having syntax error:

SQL46010: Incorrect syntax near 'jbniq_ushfbwc=l5nAxu8aapmsFT7_&#$!~<Jt}ho_aypip@'. 

VS 2017 Comminity with SSDT 15.1.61903
Shoud I change some project settings or what?

Answer :

As Aaron mentioned in the comments, try enabling containment in the database settings:

screenshot of ssdt settings

That’s after right-clicking the database project and choosing “properties” in Visual Studio.

If you are not using contained databases, use the “User” script template instead of the “User with Password” script template.

Leave a Reply

Your email address will not be published.