Wednesday 5 June 2013

Sybase - grant select to all tables in a schema

The problem is to grant a permission (select in this case) to a particular user, on all tables/views in a database.

select distinct 'grant select on ' + user_name + '.' + name + ' to username go' command from sysobjects inner join SYSUSER on SYSUSER.user_id = sysobjects.uid where type in ('U' ,'V') and user_name='database_name'

Just copy and paste the results into a command line session.

No comments:

Post a Comment