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

Posted on 2009-05-08
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 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL ( and MongoDB (…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 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