Solved

An Append Trigger

Posted on 2004-08-10
2
410 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 100 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL STANDARD CORE 8 40
Update one table with results from another table in SQL 6 28
SQL R 21 28
SQL 2008 R2 problem with DB 9 16
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

830 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