Re: How to prevent DELETEs in a table
From: Aaron [SQL Server MVP] (ten.xoc_at_dnartreb.noraa)
Date: 01/03/05
- Next message: Anith Sen: "Re: How to prevent DELETEs in a table"
- Previous message: John Smith: "Number Of Hits"
- In reply to: Dave: "How to prevent DELETEs in a table"
- Next in thread: Anith Sen: "Re: How to prevent DELETEs in a table"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 3 Jan 2005 17:12:56 -0500
You could create a trigger, e.g.
USE tempdb
GO
CREATE TABLE Employees (id INT, name CHAR(5))
GO
CREATE TRIGGER no_delete
ON Employees
FOR DELETE
AS
ROLLBACK
RAISERROR('No deletes!', 11, 1)
GO
INSERT Employees SELECT 1, 'Aaron'
INSERT Employees SELECT 2, 'Frank'
INSERT Employees SELECT 3, 'Henry'
GO
SELECT * FROM Employees
GO
DELETE Employees WHERE id=3
GO
SELECT * FROM Employees
GO
DROP TABLE Employees
-- http://www.aspfaq.com/ (Reverse address to reply.) "Dave" <dave@nospam.ru> wrote in message news:#korZ3d8EHA.1300@TK2MSFTNGP14.phx.gbl... > What is the best way to prohibit deletes in a table? > > I thought this would work: > > DENY DELETE ON EMPLOYEES TO public > > But after executing the above statement I can still perform DELETEs in the > table. > > What don't I understand? > >
- Next message: Anith Sen: "Re: How to prevent DELETEs in a table"
- Previous message: John Smith: "Number Of Hits"
- In reply to: Dave: "How to prevent DELETEs in a table"
- Next in thread: Anith Sen: "Re: How to prevent DELETEs in a table"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|