Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2008 - permission denied in database 'master'

I am new to SQL Server and I wanted to create my first table there.

create table Employee
(
    ID smallint not null
)

I use SQL Server 2008 R2 and Windows Authentication.

when I execute , it says :

CREATE TABLE permission denied in database 'master'.

Thanks!

like image 727
thormayer Avatar asked Dec 21 '22 05:12

thormayer


2 Answers

Seems you're trying to create the table in master database where you may not have permission to create table. However, to create your target database please follow below steps:

a. At your SQLQuery editor choose your target database (Available Database drop down list) and execute your sql query.

Or

b. Try with below statement:

USE YourTargetDatabaseName
GO
CREATE TABLE Employee ( ID SMALLINT NOT NULL)
GO
like image 61
Elias Hossain Avatar answered Dec 25 '22 23:12

Elias Hossain


I don't think you want to create a table in the master database.

Did you create a new database first? If so, use this:

USE [MyNewDatabaseName]
GO

create table Employee ( ID smallint not null )
GO
like image 21
danludwig Avatar answered Dec 25 '22 23:12

danludwig