locked
Create NEW Database RRS feed

  • Question

  • Hi,

    I want to grant a SQL Login permissions to be able to CREATE a NEW database on the SQL server.

    Please advice what permissions the Login needs to have to be able to do this.

    thanks.
    Sunday, January 31, 2010 8:15 AM

Answers

  • Hi

    Grant dbcreator role to user but be careful that user will get below permissons as well.


    dbcreator

     

    Members of the dbcreator fixed server role can create databases, and can alter and restore their own databases.

    Cheers
    Vishal

    • Marked as answer by RubSay Monday, February 1, 2010 12:37 PM
    Monday, February 1, 2010 12:14 PM

All replies

  • Hi,

    Hope this helps

     check below URLs for all that you are looking for ...


    http://msdn.microsoft.com/en-us/library/ms178569.aspx

    http://articles.techrepublic.com.com/5100-10878_11-1061781.html



    Regards,
    Ramakrishna
    Sunday, January 31, 2010 10:01 AM
  • Try Following Basic Syntax. For more info on Create Database http://msdn.microsoft.com/en-us/library/ms176061.aspx

    USE

     

    [master]

    GO

    CREATE

     

    LOGIN [createDB] WITH PASSWORD=N'Password1',

    DEFAULT_DATABASE

     

    =[master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF

    GO

    use

     

    [master]

    GO

    GRANT

     

    CREATE ANY DATABASE TO [createDB]

    GO

    CREATE

     

    DATABASE [MyTestDB] ON PRIMARY

    (

     

    NAME = N'MyTestDB', FILENAME = N'F:\MyTestDB.mdf' , SIZE = 3072KB , FILEGROWTH = 1024KB )

     

    LOG ON

    (

     

    NAME = N'MyTestDB_log', FILENAME = N'F:\MyTestDB_log.ldf' , SIZE = 1024KB , FILEGROWTH = 10%)

    GO

    Sunday, January 31, 2010 1:11 PM
  • Hi Rubsay,

     

    If you would like to make a login to be able to create a database at the server level , then give them at least one of the following

    grant on create database ,create any database or alter any database .

     

    SAMPLE CODE:

     

    create login jay with password ='123456'

    go

    grant create any database to jay

    go

    grant alter any database to jay

    go

    sp_addsrvrolemember 'jay','dbcreator'

    go

     

     


    Thanks, Leks
    Sunday, January 31, 2010 9:23 PM
  • Thanks Lekss..

    but isnt it enough that i create a login and assign it dbcreator server role. Will that suffice??
    Monday, February 1, 2010 10:40 AM

  • Yes, adding login to the dbcreator role is suffice for create database.
    Monday, February 1, 2010 11:16 AM
  • Hi

    Grant dbcreator role to user but be careful that user will get below permissons as well.


    dbcreator

     

    Members of the dbcreator fixed server role can create databases, and can alter and restore their own databases.

    Cheers
    Vishal

    • Marked as answer by RubSay Monday, February 1, 2010 12:37 PM
    Monday, February 1, 2010 12:14 PM