column level trigger

Posted on 2011-10-07
Last Modified: 2012-05-12
is it possible to say to the column that whenever it is updated, it should save the text in UPPER case only?
Question by:25112
    LVL 75

    Accepted Solution

    You can certainly create a TRIGGER on the table to do that, as in:
    CREATE TRIGGER trg_YourTrigger ON YourTableName
    IF UPDATE(YourColumnName)
       UPDATE t
       SET  YourColumnName = UPPER(YourColumnName)
       FROM	YourTableName t
    		INNER JOIN INSERTED i ON t.YourPrimaryKeyGoesHere = i.YourPrimaryKeyGoesHere

    Open in new window

    LVL 5

    Author Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
    Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
    Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
    Via a live example, show how to setup several different housekeeping processes for a SQL Server.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now