I have created an MSI file that installs a program. As part of the installation process, I need to create a local database using SQL Server 2016 Express on Windows 10 Enterprise. When I run the MSI, the following error occurs:
CREATE DATABASE permission denied in database 'master'.
SQL error number = 262 ==> SQL server = (local)\MYCOMPUTER --> SQL state = 1 --> Error code = -2146232060 --> SQL Error: System.Data.SqlClient.SqlError: CREATE DATABASE permission denied in database 'master'.
How can I get past this issue and create the local database? Is there a setting I need to change in SQL Server, or in my code itself?
Googling this question has told me that I need to give the user login the roles of "sysadmin" and "dbcreator", but this hasn't worked. I've disabled these roles for the user for now.
In your script add the following