HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

CREATE DATABASE permission denied in database 'master'

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
createpermissiondenieddatabasemaster

Problem

I've developed a desktop application using WPF and Entity Framework code-first.

In my application the user can create multiple databases at run-time.

But Entity Framework can't create database if the user isn't admin on his machine.

I need to find a solution that could be done with coding. Management Studio is not installed on the user's machine.

What do you suggest?

Solution

You need to execute this T-SQL command using an account that does have administrative rights, such as sa:

USE master;
EXECUTE sp_addsrvrolemember @loginame = N'YourAppUserLogin', @rolename = N'dbcreator';


Replace YourAppUserLogin with the login the application user uses to connect to the database.

Code Snippets

USE master;
EXECUTE sp_addsrvrolemember @loginame = N'YourAppUserLogin', @rolename = N'dbcreator';

Context

StackExchange Database Administrators Q#42299, answer score: 5

Revisions (0)

No revisions yet.