• shathaway 77080 (3/26/2013)


    I am still basic newbie to sql(1 year) how can I create accounts and permissions on a db from dos batch file? If you have a basic example I can take it from there.

    Thank you.

    Steve

    The login will already exist, so you need to change the context to the database.

    USE databasename

    GO

    Then create the user

    CREATE USER username FOR LOGIN loginname

    GO

    Then create the permissions you need, eg, db_owner

    EXEC sp_addrolemember 'db_owner', 'username'

    GO