Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


How do Insert records in TableB  based on a Batch insert of Records from TableA on a Trigger?

Posted on 2009-05-08
Medium Priority
Last Modified: 2012-05-06
I'm somewhat new to the use of Triggers in MS SQL. My initial creation only gives me 1 new record in the second table(SMI_STATUS) , regardless of the number of records inserted into
the firts table that fires the trigger (TicketPoolHist).

I've looked at several examples on the web, realizing that I need to do a "set" approach, but I can't seem to put it together. Any suggestions?
Currrent Trigger , which only works on the last record in the Inserted table is shown below.
CREATE TRIGGER [STLog1] ON [dbo].[TicketPoolHist] 
declare @Datestamp as datetime,
@TableName as Char(20),
@TableUID as Integer,
@Status as Char(1)
@TableUID = Identity_Column
From Inserted
INSERT INTO smi_Status(DateStamp,TABLENAME,TABLEUID,STATUS) VALUES (Current_TimeStamp,'TicketPoolHist',@TableUID,1)

Open in new window

Question by:synovacorp
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 75

Accepted Solution

Aneesh Retnakaran earned 2000 total points
ID: 24335998
SELECT Current_TimeStamp,'TicketPoolHist',i.Identity_Column,1
FROM Inserted i


Author Closing Comment

ID: 31579436
Worked perfect.
Many Thanks.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

636 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