473,382 Members | 1,377 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,382 software developers and data experts.

2005: forbidding INSERTs and DELETEs

Please help.
I have a table with single row. I need to allow only UPDATEs of the
table, forbid INSERTs and DELETEs. How to achieve it?
Thank you for information
/RAM/
Jul 6 '06 #1
3 1781
No permissions exist when a new object is created. Only privileged users
such as the object owner, sysadmin role members, the database owner and
db_owner role members have access until permissions are granted. To grant
only UPDATE permissions:

GRANT UPDATE ON dbo.MyTable TO SomeRole

--
Hope this helps.

Dan Guzman
SQL Server MVP

"R.A.M." <r_********@poczta.onet.plwrote in message
news:4l********************************@4ax.com...
Please help.
I have a table with single row. I need to allow only UPDATEs of the
table, forbid INSERTs and DELETEs. How to achieve it?
Thank you for information
/RAM/

Jul 6 '06 #2
R.A.M. (r_********@poczta.onet.pl) writes:
I have a table with single row. I need to allow only UPDATEs of the
table, forbid INSERTs and DELETEs. How to achieve it?
CREATE TRIGGER update_only FOR INSERT, DELETE AS
RAISERROR('INSERT and DELETE not permitted on this table!', 16, -1)
ROLLBACK TRANSACTION

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jul 6 '06 #3
On Thu, 06 Jul 2006 13:42:39 +0200, R.A.M. wrote:
>Please help.
I have a table with single row. I need to allow only UPDATEs of the
table, forbid INSERTs and DELETEs. How to achieve it?
Thank you for information
/RAM/
Hi RAM,

Dan already replied how to do this with GRANT and DENY. If you also must
keep the database owner and administrators from accidentally inserting
or deleting a row, add the following trigger:

CREATE TRIGGER NoInsertOrDelete
ON SingleRowTable
AFTER INSERT, DELETE
AS
IF @@ROWCOUNT = 0 RETURN
ROLLBACK TRANSACTION
RAISERROR ('Don''t add rows to or remove rows from this table!', 16, 1)
GO

--
Hugo Kornelis, SQL Server MVP
Jul 6 '06 #4

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

Similar topics

3
by: kerri | last post by:
Hi, I need to do a mysqldump of specific inserts, updates & deletes. I read in the docs that I can use -w or --where. Can I do a join? Could someone provide an example? Is there another...
4
by: Tony | last post by:
Is there any known SQL Server bug whereby a record can be successfully inserted and committed, but then later be found not to be in the database? For example, if there was a server crash just...
3
by: Viswanatha Thalakola | last post by:
Hello, Can someone point me to getting the total number of inserts and updates on a table over a period of time? I just want to measure the insert and update activity on the tables. Thanks....
2
by: Paul Aspinall | last post by:
Hi I wrote quite a few apps with .NET 1.0 and 1.1, which made use of a Data Access Layer, and also used the Microsoft Application Blocks for Data Access (v2). In VS 2005, there is a huge...
4
by: ~john | last post by:
I'm trying to get a transaction to work with PHP 5.1.4 and SQL Server 2005... The first SQL statement deletes several rows in the database. The next SQL statement loops through and inserts several...
0
by: Benzine | last post by:
I recently rolled out replication on our production server (MS SQL 2000 SP4) and every time a subscriber tries to sync the following always appears in the Merge Agent History: "Downloaded 100...
2
by: Graville | last post by:
All, OK wasn't sure where to post this one but this should hopefully be ok. I am looking for a way to streamline some of the process within our dev team. One of the areas that often takes time...
1
by: deswar | last post by:
I have a table(ACCOUNT) which has 30+ columns. There can be Inserts/Updates/Deletes to this table. My requirement is to create triggers for Insert/Update/Delete and store previous value and latest...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.