Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

prevent DELETE and/or UPDATE
Hi all!
Are there any other way than using rights or Triggers to prevent a
DELETE or an UPDATE on a specific column.

The "problem" with rights is that they dont apply to all DB-users

The "problem" with triggers is that they generate lots of extra
SQL-code

I would like a solution something like below. If there are any
primitives like this or other more neat solutions I would be glad to
know



CREATE TABLE some_table NO DELETE
/*                      ^^^^^^^^^*/
(
some_column SOME_TYPE NO UPDATE
/*                    ^^^^^^^^^*/

)


For clarity, here is a trigger that currently solves the problem

CREATE TRIGGER  check_updateable_col
umns ON some_table
FOR UPDATE
AS
IF UPDATE(some_column)
RAISERROR(...)
GO

or

CREATE TRIGGER delete_not_allowed ON some_table
INSTEAD OF DELETE
AS
RAISERROR(...)
GO

Report this thread to moderator Post Follow-up to this message
Old Post
Jon
04-21-05 02:23 PM


Re: prevent DELETE and/or UPDATE
I don't understand this statement:

> The "problem" with rights is that they dont apply to all DB-users".

You can set DB permissions for whatever users you like. True, you can't
stop sysadmins from updating tables but that's not possible with
triggers or any other method either. Nor would it be a good idea since
corrective maintenance may be part of a DBA's role.

The problem with attempting to do this in a trigger is precisely that
there isn't an easy way to circumvent the trigger for ad-hoc
maintenance purposes without affecting all other users. A Trigger
containing only a RETURN statement should do for this if you must.

However, if you enforce the sensible practice of denying users all
permissions on tables and then performing updates only through procs
you won't have this problem.

--
David Portas
SQL Server MVP
--


Report this thread to moderator Post Follow-up to this message
Old Post
David Portas
04-21-05 02:23 PM


Sponsored Links





Last Thread Next Thread
Post New Thread

Microsoft SQL Server forum archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 04:47 AM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006