Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql instruction

Author  Topic 

craker
Starting Member

5 Posts

Posted - 2010-01-20 : 10:56:35
i need with one sql instruction that

nobody in my database can drop or alter views

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-01-20 : 11:11:06
[code]CREATE Trigger ProtectViews
on database
for alter_view, drop_view
AS

RAISERROR ('Views may not be modified', 10, 1)
ROLLBACK[/code]

see here: http://msdn.microsoft.com/en-us/library/ms186406.aspx
Go to Top of Page

craker
Starting Member

5 Posts

Posted - 2010-01-20 : 11:16:43
and if i want that everybody can execute select in every tables on database
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-01-20 : 11:27:55
can add them to db_datareader role.

exec sp_addrolemember @rolename = 'db_datareader', @membername = 'user name here'

or

exec sp_addrolemember @rolename = 'db_datareader', @membername = 'guest'

or grant select on <table name> to public
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-01-20 : 19:21:56
Manuel...is that you????

-- Mr. Fawlty



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-01-20 : 19:43:24
Go to Top of Page
   

- Advertisement -