Tuesday, March 27, 2012

Grant select permission on all tables

Hi Gurus, Can any one tell me how to grant select permisision all tables in a DB
like Grant all on [all tables] to myuser.
Thanks in advance.
Srinivas varanasiUse the Information Schema views...like

SELECT 'GRANT SELECT ON ' + TABLE_NAME + ' TO USER'
FROM INFORMATION_SCHEMA.Tables

Now this is from the public library 9:30 sat morning folks, so check the syntax...

No testing here|||another idea is

sp_addrolemember 'db_datareader' ,
'[domain\username] or [username]'

thats not exactly a 'grant' but it will give the user read access to all tables in the database.sql

No comments:

Post a Comment