I’m going to add what I’ve had to do, as it is an amalgamation of the above.
I’m using Code First, tried using ‘create-database’ but got the error in the title.
Closed and re-opened (as Admin this time) — command not recognised but ‘update-database’ was so used that. Same error.
Here are the steps I took to resolve it:
1) Opened SQL Server Management Studio and created a database «Videos»
2) Opened Server Explorer in VS2013 (under ‘View’) and connected to the database.
3) Right clicked on the connection -> properties, and grabbed the connection string.
4) In the web.config I added the connection string
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=MyMachine;Initial Catalog=Videos;Integrated Security=True" providerName="System.Data.SqlClient"
/>
</connectionStrings>
5) Where I set up the context, I need to reference DefaultConnection:
using System.Data.Entity;
namespace Videos.Models
{
public class VideoDb : DbContext
{
public VideoDb()
: base("name=DefaultConnection")
{
}
public DbSet<Video> Videos { get; set; }
}
}
6) In Package Manager console run ‘update-database’ to create the table(s).
Remember you can use Seed() to insert values when creating, in Configuration.cs:
protected override void Seed(Videos.Models.VideoDb context)
{
context.Videos.AddOrUpdate(v => v.Title,
new Video() { Title = "MyTitle1", Length = 150 },
new Video() { Title = "MyTitle2", Length = 270 }
);
context.SaveChanges();
}
- Remove From My Forums
-
Question
-
Hello Everyone,
I just bought a new computer, installed Windows 10 pro, sql server 2014 Express + SSMS 2016 Preview.
I have done this many times before and it always worked.
- I start SSMS «As Administrator» with Windows Authentication Mode.
- Then I try to create a new Database and I get an exception message.
CREATE DATABASE permission denied in database ‘master’. (Microsoft SQL Server, Error: 262)
SSMS 2014 Express did not work either.
I would any appreciate any help greatly! Kindest Blessings
Andreas Bolliger
Answers
-
Dear Andreas,
restart the sql server service in single user mode.
You have to add -m as a startup parameter in configuration manager and restart the service:
From this point you will be able to connect with any local windows administrator via sqlcmd as a sysadmin (only possible in single user mode for fixing those issues)
sqlcmd -S .<YourInstance>
Now create your missing login
CREATE LOGIN [<YourLogin>] FROM WINDOWS;
GO
Do not forget to add the created login to the sysadmin server role:
exec sp_addsrvrolemember [<YourLogin>], sysadmin; GO
Remove the -m startup parameter in SQL Server configuration manager, restart your instance and you will be able to be the real sysadmin.
PS: the correct way is realy to add an administrative login during setup. But afterwards this way will fix your problem without re-installing your sql server.
Best Regards
Kai
-
Proposed as answer by
Wednesday, May 11, 2016 8:33 PM
-
Edited by
Koppelmann, Kai
Wednesday, May 11, 2016 8:34 PM
Formatting -
Marked as answer by
BolligeA
Wednesday, May 11, 2016 8:40 PM
-
Proposed as answer by
I am making a database in sql server and it shows an error that "CREATE DATABASE permission denied in database 'master'"
I am using the administrator log in itself.
What i need to do?
Please suggest a fix!

asked Aug 31, 2014 at 7:09
1
The user must be a member of dbcreator server role for user to have enough permissions to create a database.
You can execute the following statement to make a user member of dbcreator server role.
EXEC master..sp_addsrvrolemember @loginame = N'Shubhankar', @rolename = N'dbcreator'
GO
Or you Can/Should use
ALTER SERVER ROLE [dbcreator] ADD MEMBER [Shubhankar];
GO
Members of sysadmin role are by default members of dbcreator server role therefore they can create databases too.
answered Aug 31, 2014 at 12:49
![]()
M.AliM.Ali
1,9209 gold badges27 silver badges37 bronze badges
1
All the above points are clear but there is one which is missing. I struggled to find the solution to this problem and finally got it after long research.
To get permission to create database in your local account follow the below given steps.
Step 1: Disconnect from your local account.
Step 2: Again Connect to Server with Login : sa and Password : pwd(pwd given to your local login).
Step 3: Object Explorer -> Security -> Logins -> Right click on your server name -> Properties -> Server Roles -> sysadmin -> OK
Step 4: Disconnect and connect to your local login and create database.
Successfully created the database

answered Aug 10, 2016 at 3:28
user103167user103167
511 silver badge1 bronze badge
I was having same problem, I noticed I was connected using Windows Authentication. I then disconnected and used SQL Server Authentication. It started good.
answered Feb 1, 2017 at 19:41
![]()
If you’re in Azure, the command is a little different:
ALTER ROLE [dbmanager] ADD MEMBER [Shubhankar];
answered Jun 16, 2021 at 17:26
Hi friends! In this article, we’ll be discussing about “SQL Server error 262: CREATE DATABASE permission denied in database ‘database_name’, and how you can resolve it.
About the above “permission denied” error
This error serves as a reminder that not every user in a SQL Server environment has the authority to create databases. This error means that the user who is attempting to execute the CREATE DATABASE statement does not have the appropriate access to perform this action within the given database.
This issue often results from the user account trying to create the database having insufficient administrative access or privileges. The CREATE DATABASE statement can only be successfully used by users who have the necessary administrative rights or particular permissions for creating databases.
Other factors for the “permission denied” error in the CREATE DATABASE SQL statement
Another factor that may contribute to the error we are examining in this article, is the user’s context and the current database in use. It is important to note, that the CREATE DATABASE SQL statement, should be executed within the context of the master database, which holds the necessary authority to create new databases. If the command is issued within a different database without the required permissions, the error message will be generated.
Let’s see an example
Let’s use an example to demonstrate this permission error. Let’s assume that we have been given the task of setting up a new database on a SQL Server instance with the name “SalesDB”. However, when we try to create the database, we get the error “SQL Server error 262: CREATE DATABASE permission denied in database ‘master’”. It is clear from this situation that our user account does not have the necessary permissions to create the database. In this case, we need the assistance of a higher-level administrator or a user with sufficient privileges to correctly run the CREATE DATABASE command to fix this problem.
Remarks
Giving the user account that is executing the CREATE DATABASE statement the necessary permissions is often the first step in fixing this error. To ensure a proper execution of the database creation process, it is crucial to comprehend the user’s security context, the target database, and the applicable permissions.
It’s important to keep in mind that, despite the SQL Server error 262 appearing to be a challenge, a solid understanding of permissions and administrative roles will enable you to go around it and successfully build databases in your SQL Server environment.
Strengthen your SQL Server Administration Skills – Enroll to our Online Course!
Enroll to our online course on Udemy titled “Essential SQL Server Administration Tips”
(special limited-time discount included in link).Via the course, you will learn essential hands-on SQL Server Administration tips on SQL Server maintenance, security, performance, integration, error handling and more. Many live demonstrations and downloadable resources included!
(Lifetime Access/ Live Demos / Downloadable Resources and more!) Enroll from $12.99
Featured Online Courses:
- SQL Server 2022: What’s New – New and Enhanced Features
- Working with Python on Windows and SQL Server Databases
- Introduction to Azure Database for MySQL
- Boost SQL Server Database Performance with In-Memory OLTP
- Introduction to Azure SQL Database for Beginners
- Essential SQL Server Administration Tips
- SQL Server Fundamentals – SQL Database for Beginners
- Essential SQL Server Development Tips for SQL Developers
- Introduction to Computer Programming for Beginners
- .NET Programming for Beginners – Windows Forms with C#
- SQL Server 2019: What’s New – New and Enhanced Features
- Entity Framework: Getting Started – Complete Beginners Guide
- Data Management for Beginners – Main Principles
- A Guide on How to Start and Monetize a Successful Blog
Read Also:
- Advanced SQL Server Features and Techniques for Experienced DBAs
- SQL Server 2022: What’s New – New and Enhanced Features (Course Preview)
- SQL Server 2022 Generally Available!
- An existing History Table cannot be specified with LEDGER=ON – How to Resolve
- SQL Server 2022 Overview: A Hybrid Data Platform
- Azure Synapse Link in SQL Server 2022
- What is Data Management and why it is Important?
- What is Data Security and which are its Main Characteristics?
- Data Security vs. Data Privacy
- What are NoSQL Databases?
- Differences Between Batch and Streaming Data
- What is Data Compliance within the Data Management Scope?
- How to Connect to SQL Server Databases from a Python Program
- How to Resolve: [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)
- Useful Python Programming Tips
- Main Data Structures in Python
- Working with Python on Windows and SQL Server Databases (Course Preview)
- How to Write to a Text File from a C++ Program
- How to Establish a Simple Connection from a C# Program to SQL Server
Subscribe to our newsletter and stay up to date!
Subscribe to our YouTube channel (SQLNetHub TV)
Check our eBooks!
Rate this article: 



(1 votes, average: 5.00 out of 5)
Loading…
Reference: SQLNetHub.com (https://www.sqlnethub.com)
© SQLNetHub
Artemakis Artemiou is a Senior SQL Server Architect, Author, a 9 Times Microsoft Data Platform MVP (2009-2018). He has over 20 years of experience in the IT industry in various roles. Artemakis is the founder of SQLNetHub and {essentialDevTips.com}. Artemakis is the creator of the well-known software tools Snippets Generator and DBA Security Advisor. Also, he is the author of many eBooks on SQL Server. Artemakis currently serves as the President of the Cyprus .NET User Group (CDNUG) and the International .NET Association Country Leader for Cyprus (INETA). Moreover, Artemakis teaches on Udemy, you can check his courses here.
Views: 120
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit «Cookie Settings» to provide a controlled consent. Read More
Sql Server error 262 is common issue faced by SQ Server users when trying to create new database in SQL Server Management Studio. This error can appear also during login on SSMS. A message is returned that states that the account does not have “sysadmin” role to SQL Server.
Another reason si that starting with SQL 2008, local Administrators group is no longer added by default during SQL Server setup. You even have to use a manual step to add the current user as a local administrator. This means that it is possible, especially if you don’t use mixed authentication (or have forgotten the sa password), that you can be completely locked out of your own SQL Server instance.
For any reason you don’t have any account available on SQL Server with “sysadmin” role. So you can’t edit other users to add the specific database on their “user mapping”. The following article will tech how to fix those issue with privileges and permissions.
Error:
CREATE DATABASE permission denied in database ‘master’. (Microsoft SQL Server, Error: 262)

SQL Server error 262
SQL server error 262
Case 1 – You have a login available account with “sysadmin” role.
This case assumes that you have an account with sysadmin roles on SQL Server like an Admin. During the setup of SQL Server you must have specified (at least one) system administrator for the instance of SQL Server, or SA account if you are using mixed mode authentication. You need to use credentials for that account to gain access to your SQL Server.
After accessing the SQL Server Management Studio with this account you can create or edit other users (The user that having the error in his case) in order to have sysadmin role.
- Log on to the computer using the credentials for the Administrator account.
- Click the Start button, point to All Programs, click Microsoft SQL Server, and then click SQL Server Management Studio.
- Connect to the instance of SQL Server.
- Click Security, right-click Logins, and then click New Login.
- In the Login name box, enter the user name.
- In the Select a page , click Server Roles, select the sysadmin check box, and then click OK.
Case 2 – How to gain sysadmin access on SQL Server when you don’t have any user with “sysadmin” role.
The worst case is when you don’t have any sysadmin user to login on the system. The single option is to start SQL server in a single user mode, in that case anyone who is local administrator on that computer can connect to SQL Server as a member of sysadmin fixed server role.
Start the instance of SQL Server in single-user mode by using either the -m or -f options. Any member of the computer’s local Administrators group can then connect to the instance of SQL Server as a member of the sysadmin fixed server role.
Make sure you stop SQL agent service, before you put SQL server service in Single user mode else you can error saying only one user can be connected.
- Stop the SQL Server Service:
- Use SQL Server Configuration manager and stop the SQL service or use services to locate and stop SQL Service.
- Start SQL Server in Single User mode
- Use start-up parameter m to start SQL Service in single user mode.
- “net start MSSQLServer /m SQLCMD” if you want to use command line
- Using configuration Manager – Locate the service which you have stopped earlier. Go to its properties, “Advanced”, click on drop down at “Startup Parameters” and add ;-m
- Use start-up parameter m to start SQL Service in single user mode.
- Connect to SQL Server and add desired account in SysAdmin role.
- Open administrator command prompt. (i.e. right click on command prompt shortcut and choose “Run As Administrator”
- Type sqlcmd –S For example
- sqlcmd –S. (for default instance)
- sqlcmd –S.MyInstance
- You are connected as System Administrator, because you are part of local administrator group in windows.
- Use this script I normally use to add local administrator group as a part of SysAdmin group in SQL Server Instance.
USE [master]
GO
CREATE LOGIN [DomainUsername] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
EXEC master..sp_addsrvrolemember @loginame = N’ DomainUsername, @rolename = N’sysadmin’
GO
- Stop SQL Server Service.
- Remove startup parameter and Start SQL Service normally
This procedure is described on MSDN
Read also other SQL Server Helping Posts:
- Find Location of SQL Server Error Log
- SQL Server Error 300
- Restore Master Database
Case 3 – Adding specific permissions to the user
Grant SHOWPLAN access to the SQL user
SQL Server Error 262 can appear when user tries to check the execution plan using CTRL + M. A calculated execution plan is a SQL Server query plan that is created without actually running the query plan. Its main purpose is to check how query will behave without having to execute it. In order to include the execution plan in the query, we can allow user to grant SHOWPLAN access to the user. Fixing the error is possible by providing particular user the SHOWPLAN access using following commands:
USE DatabaseName
GO
GRANT SHOWPLAN TO UserName
GO
We can run the commands in the database where user faces the issue to make them view the query execution plan without any complications.
Let me know if you have any issue with the solutions regarding the Sql Server error 262.

