473,396 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

prevent DELETE and/or UPDATE

Jon
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_columns 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
Jul 23 '05 #1
1 6434
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
--

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Alex | last post by:
Hi, I have tables that have default records that must not be deleted or modified. Is there an easy way to do this. Like setting a trigger on the Primary key value ? Alex
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
1
by: KEVIN97810 | last post by:
Hello to all, I read data from SQL and populate a table. Howerver, there are dups that I need to prevent into my table. The dups only are in these two fields. How do you prevent this in the...
10
by: mttc | last post by:
I read articles that suggest preventing delete by throwing Exception from RowDeleting Event. I not understand where I can catch this Error?
5
by: Maria Anthonsen | last post by:
I have filled a datagrid with data from a dataset. The dataset was filled with a dataadapter - and I used the wizard to create insert, update, delete commands. I would like to prevent the user...
1
by: Leanne | last post by:
I am doing customization for microsoft POS. I manually added a record to a table. The manage and maintenance of this table are done by POS, and user can update the contents of this table. Is there...
5
by: rn5a | last post by:
The .NET 2.0 documentation states the following: When using a DataSet or DataTable in conjunction with a DataAdapter & a relational data source, use the Delete method of the DataRow to remove...
11
by: ariel81 | last post by:
i have created a function to input data from four textboxes into a table. how do i prevent duplicate records of the same mth/Yr into the table? editing of the data in the table with reference to the...
3
by: MyWaterloo | last post by:
Heya... Thanks in advance if you can help... or at least understand my gibberish. I have 2 tables, let's call them tblBacT and tblBacTData, they are related through the auto number primary key...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.