Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8742067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:26:05+00:00 2026-06-13T11:26:05+00:00

Question: In our SQL-Server 2005 database, we have a table T_Groups. T_Groups has, amongst

  • 0

Question:
In our SQL-Server 2005 database, we have a table T_Groups.
T_Groups has, amongst other things, the fields ID (PK) and Name.

Now some idiot in our company used the name as key in a mapping table…
Which means now one may not alter a group name, because if one does, the mapping is gone…

Now, until this is resolved, I need to add a restriction to T_Groups, so one can’t update the group’s name.
Note that insert should still be possible, and an update that doesn’t change the groupname should also be possible.

Also note that the user of the application & the developers have both dbo and sysadmin rights, so REVOKE/DENY won’t work.

How can I do this with a trigger ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:26:06+00:00Added an answer on June 13, 2026 at 11:26 am
    CREATE TRIGGER tg_name_me
    ON tbl_name
    INSTEAD OF UPDATE
    AS
    IF EXISTS (
       SELECT *
       FROM INSERTED I
       JOIN DELETED D ON D.PK = I.PK AND ISNULL(D.name,I.name+'.') <> ISNULL(I.name,D.name+'.')
    )
    RAISERROR('Changes to the name in table tbl_name are NOT allowed', 16,1);
    GO
    

    Depending on your application framework for accessing the database, a cheaper way to check for changes is Alexander’s answer. Some frameworks will generate SQL update statements that include all columns even if they have not changed, such as

    UPDATE TBL
       SET name = 'abc', -- unchanged
           col2 = null, -- changed
           ... etc all columns
    

    The UPDATE() function merely checks whether the column is present in the statement, not whether its value has changed. This particular statement will raise an error using UPDATE() but won’t if tested using the more elaborate trigger as shown above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our DB (on SQL Server 2005) we have a Customers table, whose primary
At our organization we have a SQL Server 2005 database and a fair number
We have a few tables in our SQL Server (2005 & 2008) database with
I have a table in a SQL Server 2005 Database that is used a
I have an existing SQL Server 2005 database that runs our accounting/inventory application. We
We have a SQL Server 2005 database, and currently all our users are connecting
Our program ships with an SQL Server 2005 database and SQL Server 2005 Express.
In our SQL Server 2005 database (tested using Management Studio with DBCC FREEPROCCACHE and
I have a question about why some SQL (running on SQL Server 2005) is
Running SQL Server 2005. A piece of software integrates with our database. Unfortunately they

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.