Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Can a record be read only

Author  Topic 

cbecerra
Starting Member

38 Posts

Posted - 2002-08-23 : 11:27:34
I'm interested in finding out if there is a way to mark a record as read only.


Thanks
>cesar

MichaelP
Jedi Yak

2489 Posts

Posted - 2002-08-23 : 12:13:29
Not that I know of in SQL Server.

What exactly are you trying to accomplish? You probably need some sort of "ReadOnly" BIT field for the table.

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-08-23 : 12:15:32
No; that's more of a flat-file concept. You can deny update or delete permissions on a table, or update permissions on a given column, but there isn't a way at the database layer to single out a specific row.

Jonathan Boott, MCDBA
{0}
Go to Top of Page

cbecerra
Starting Member

38 Posts

Posted - 2002-08-23 : 12:25:09
This is the issue I have a small application where users can access and modify information on the database, however there is some particular records that although I want the user to be able to see but not to modify.

Michael, what exactly do you mean by a "ReadOnly BIT".


.Cesar

Go to Top of Page

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-08-23 : 12:28:48
quote:

... there isn't a way at the database layer to single out a specific row.


The readonly bit idea is to add a bit column to your table and have the data access layer determine whether or not the row can be changed depending on the value of the bit.

Could you expand on your environment a little? Specifically are you running SQL Server, and if so what version?

You may find the best way to handle your situation is to split the table in question into 2 - one where users can change data and one where they can't, and then create a view that unions the two together.

Jonathan Boott, MCDBA
{0}
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2002-08-23 : 12:42:22
What I ment by the "readonly bit" is add a field that is of type BIT to the tables in question. Then, whenever you need to make the record readonly, update the field to 1. Your application needs to look at the BIT field to determine if it should allow the user to eit the record.

I know that's probably a bit hard to understand, but it's the best I can do right now :) Ask more questions about this if you need to though.

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>

Edited by - michaelp on 08/23/2002 12:42:41
Go to Top of Page

dsdeming

479 Posts

Posted - 2002-08-23 : 12:55:16
What about using INSTEAD OF UPDATE and INSTEAD OF DELETE triggers to test the setting of the readonly bit? You could bail out if the column is set to 1.

See Designing INSTEAD OF Triggers in BOL.

Go to Top of Page
   

- Advertisement -