You are here: Re: prevent one single row from being updated « MsSQL Server « IT news, forums, messages
Re: prevent one single row from being updated

Posted by Erland Sommarskog on 11/08/06 08:40

Leanne (leannewu@connectretail.com.au) writes:
> 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 any way I can
> lock this single row at database level to prevent it from being deleted
> or changed by user? I am using SQL 2000 and vb.net.

You could add a trigger:

CREATE TRIGGER tri ON tbl FOR UPDATE, DELETE AS
IF EXISTS (SELECT * FROM deleted WHERE key col = <yourrow>)
BEGIN
ROLLBACK TRANSACTION
RAISERROR('Hey, that is my row! Don''t mess with it!', 16, 1)
RETURN
END




--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация