Running the following (generated by Sql Server Management Studio) on Sql Server 2008 Express under Vista:

( NAME = N'test', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\test.mdf' , SIZE = 5120KB , FILEGROWTH = 10%)
( NAME = N'test_log', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\test_log.ldf' , SIZE = 1024KB , FILEGROWTH = 10%)

results in

Msg 262, Level 14, State 1, Line 1
CREATE DATABASE permission denied in database 'master'.

The surface area tool I found references to for sql 2005 no longer exists and I can't figure out how to add local admins (of which I am one) to db admins for sql express.

As far as I'm aware this is a fairly standard install.

How do I create a new database?


The 2008 R2 installer asks you during the install to pick which user will be a sql server administrator. It does not make the local admin account a sql server sysadmin like in previous versions. If you do not know what user you made admin during the install (or the user was deleted) then you'll have to start sql server in single usermode and add your own account in as a sysadmin.

You can follow these instructions
Make sure you right-click and run sqlcmd "as Administrator" For step 5, you should add your windows account as a login and then add it to the sysadmin server role with the following two commands:

exec sp_addlogin [YOULOCALMACHINENAME\YourUsername]
exec sp_addsrvrolemember [YOULOCALMACHINENAME\YourUsername], 'sysadmin'

You should then have the privs you need to run the CREATE DATABASE statement & have it work!

  • Single user mode: * start > all programs > open sql server configuration manager > Microsoft SQL Server 2008 R2 > Configuration Tools > SQL Server Configuration Manager * under Sql Server Services, right-click the default instance "SQL Server (SQLEXPRESS)", and click stop * right-click the instance again and click properties * select the advanced tab * find "Startup Parameters" in the list and add ";-m" to the end (without the quotes), click ok, and ok for the warning for restarting * right-click the service again and click start "SQL Server started in single-user mode" in the application log – Tim Abell Aug 23 '10 at 8:20
  • hrmph, it ate all my linefeeds – Tim Abell Aug 23 '10 at 8:20
  • create login [domain\tim.abell] from windows; go; msdn.microsoft.com/en-us/library/ms189751.aspx – Tim Abell Aug 23 '10 at 8:37
  • exec sp_addlogin [domain\tim.abell], 'sysadmin'; go; (I needed to quote the username in square brackets) technet.microsoft.com/en-us/library/ms186320.aspx – Tim Abell Aug 23 '10 at 8:40
  • hrm, after all that I'm still not getting the permissions, and the user isn't showing up in the list of users or under the sysadmin role. – Tim Abell Aug 23 '10 at 8:44

Try to login as 'sa' (with correspondent password) with sql server authentication mode.

  • I would like to stick to integrated auth. – Tim Abell Aug 20 '10 at 10:48
  • Log in with the sa account, as sergey mentioned, and create your additional accounts. From that point you can start using integrated authentication. – Coding Gorilla Aug 20 '10 at 14:43
  • express has sa disabled by default – Nick Kavadias Aug 20 '10 at 15:08

Have you tried using OSQL command line tool, and logging in using integrated authentication by using the -E switch. You should not use the -U and -P (username/password) swtiches.

Make sure you are logged in as an Administrator. From OSQL you could then execute your creation scripts.

  • r2 doesn't add the built-in admin as a sql server sysadmin, so it wont work ;-) – Nick Kavadias Aug 20 '10 at 15:24

Try this, it Worked:

exec sp_addlogin [YOULOCALMACHINENAME\YourUsername]
exec sp_addsrvrolemember [YOULOCALMACHINENAME\YourUsername], 'sysadmin'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.