Mr.Bua
Mr.Bua

Reputation: 158

Create a new database problem

I'm logging in to create a new database from CMD through sqlcmd with SA account. Its response is a message: CREATE DATABASE permission denied in database 'master'.

I'm using Windows server 2003 and SQL 2008. Please help me. Thanks in advance.

Upvotes: 2

Views: 254

Answers (4)

Rob Farley
Rob Farley

Reputation: 15849

It doesn't sound like you're actually using the sa account, or else perhaps you haven't set up your service account properly using SQL config mgr. If you used Computer Manager | Services, then the service might not have permission to create the database files.

Upvotes: 1

Piotr Rodak
Piotr Rodak

Reputation: 1941

I would check whether the user you are using indeed has CREATE DATABASE permission though. You can check what server roles it belongs to, because it seems it is not a sysadmin role.

You can use this query for example.

select suser_name(role_principal_id) [login ...], 
suser_name(member_principal_id) [... belongs to] 
from sys.server_role_members

Regards

Piotr

Upvotes: 0

John Feminella
John Feminella

Reputation: 311436

Typically the user you're using to run the SQL Server service will not have access to certain folders, which is likely why you're getting this error.

Consider one of these alternatives:

  • change the credentials used for the service (ick!)
  • use runas /u:... or Run as...
  • add permission for the service to access those folders
  • move the database to a location that the service can access

Upvotes: 0

George Johnston
George Johnston

Reputation: 32258

...Run As Administrator should do the trick.

Upvotes: 0

Related Questions