Results 1 to 7 of 7

Thread: PK column

  1. #1
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Unanswered: 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??

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Ummmm..huh

    Code:
    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
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Quote Originally Posted by Brett Kaiser
    Ummmm..huh
    Yeah, what Brett said.

    -PatP

  4. #4
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    use pubs
    go
    deny update, delete on authors (au_id) to public
    go
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  5. #5
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    thank you

    thank you so much guys I appreciate it . How do you donate to this website anyways??

  6. #6
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    sorry

    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???

  7. #7
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Then this will suffice:

    deny update on <your_table>(<your_primary_key>) to <your_users_or_public>
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •