Solved

An Append Trigger

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
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.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

777 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