среда, 1 сентября 2010 г.

Даем группе public Доступ

declare @table_name nvarchar(100), @sql_select nvarchar(1000)

declare sql_script cursor for
select table_name
from information_schema.tables t
where table_name not in(select distinct table_name from information_schema.table_privileges where grantee ='public')
order by table_name

open sql_script
fetch next from sql_script
into @table_name

while @@fetch_status = 0 begin
set @sql_select = 'GRANT SELECT, UPDATE, DELETE, INSERT, REFERENCES ON '+rtrim(@table_name)+' TO PUBLIC'
exec(@sql_select)

fetch next from sql_script
into @table_name
end

close sql_script
deallocate sql_script