So I have an application that automatically creates a new database after the database it is currently in reaches a fixed number of rows. I need to be able to automatically assign a user within the installation the db_datareader role for the automatically created database. I'm kind of at a loss here, any help is greatly appreciated.
SQL Server 2008 R2 – Automatically Granting Permissions to Application Created Databases
sql serverwindows
Related Question
- Sql-server – Login to SQL Server 2008 R2 remotely
- SQL Server: Database Role for .NET Program to Retrieve MSDB Table and View Rows
- SQL Server – Automatically Set Read Only Permission for New Databases
- Sql-server – How to grant execute permissions to a stored procedure but not to the underlying databases
- Sql-server – How to create a SQL Server user that can restore databases to a database server
- SQL Server – Grant Permissions to All Databases Using Server Role
- Sql-server – Simultaneous SQL full backups of newly created databases
- SQL Server – Automatic Full Backup for New Databases Created with EntityFramework-Migrations
Best Answer
Add the user to the DB_READER role. Like this:
Copied from https://stackoverflow.com/questions/456346/t-sql-to-grant-db-datareader-and-db-datawriter