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
 Transact-SQL (2000)
 A trigger question

Author  Topic 

mbrijun
Starting Member

1 Post

Posted - 2005-10-27 : 04:09:11
Good morning,

Being a newbie to SQL, I would like your advise on how to write a simple trigger to make sure, that after inserting a row in a table, certain fields of the row inserted would be changed to upper case. Thanks very much in advance.

Kristen
Test

22859 Posts

Posted - 2005-10-27 : 04:34:35
Hi mbrijun, Welcoem to SQL Team!

Untested, but try this:

CREATE TRIGGER MyTrigger
ON MyTable
AFTER INSERT, UPDATE
AS
UPDATE U
SET MyColumnA = UPPER(MyColumnA),
MyColumnB = UPPER(MyColumnB)
FROM MyTable U
JOIN inserted AS I
ON I.MyPrimaryKey = U.MyPrimaryKey
GO

Kristen
Go to Top of Page
   

- Advertisement -