Wednesday, March 7, 2012

PK column

I need to make is to my users can not accidentally delete or replace the pK field, how do I do that anyone got any suggestions??Ummmm..huh :confused:

USE Northwind
GO

CREATE TABLE myTable99(Col1 int PRIMARY KEY)
GO

INSERT INTO myTable99(Col1) SELECT 1 UNION ALL SELECT 2
GO

SELECT * FROM myTable99
GO

DELETE FROM myTable99 WHERE Col1 = 1
GO

SELECT * FROM myTable99
GO

UPDATE myTable99 SET Col1 = 1 WHERE Col1 = 2
GO

SELECT * FROM myTable99
GO

DROP TABLE myTable99
GO|||Ummmm..huh :confused:Yeah, what Brett said.

-PatP|||use pubs
go
deny update, delete on authors (au_id) to public
go|||thank you so much guys I appreciate it :). How do you donate to this website anyways??|||I explained that incorrectly what I am trying to say is I dont want my users to delete, or replace the data in the primary key field. Does that Make sense?|||Then this will suffice:

deny update on <your_table>(<your_primary_key>) to <your_users_or_public>

No comments:

Post a Comment