[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

An Append Trigger

Posted on 2004-08-10
2
Medium Priority
?
429 Views
Last Modified: 2006-11-17
I need to create a trigger that appends "-ABCD" to a field where "-ABCD" doesn't already exist at the end of the field.  


  Can anyone help??

Thanks,
  MysticalFever
0
Comment
Question by:mysticalfever
  • 2
2 Comments
 
LVL 14

Accepted Solution

by:
Thandava Vallepalli earned 400 total points
ID: 11762584
Hi here is your trigger



CREATE TRIGGER trigger_name ON employee
FOR INSERT, UPDATE
AS
      
declare @x varchar(200)
      SELECT @x=lname FROM inserted
      IF not (@x like '%-ABCD')
      begin
            update employee set lname = '%-ABCD'
            where emp_id = (select emp_id from inserted)
      end

GO


itsvtk
0
 
LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 12338674
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

834 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