SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Trigger how to?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 05/30/2013 :  05:21:00  Show Profile  Click to see raysefo's MSN Messenger address  Reply with Quote
Hi,

I have a table as follows;

CREATE TABLE [dbo].[A](
	[MatchID] [nvarchar](100) NULL,
	[MatchCode] [nvarchar](100) NULL,
	[SpecialEventCode] [nvarchar](100) NULL,
	[IncidentID] [nvarchar](100) NULL,
	[Team] [nvarchar](10) NULL,
	[Minute] [nvarchar](10) NULL,
	[Score] [nvarchar](50) NULL,
	[deleteInfo] [nvarchar](10) NULL,
	[Player] [nvarchar](100) NULL
) ON [PRIMARY]


I would like to write a trigger and everytime a record is inserted into this table, I want this trigger to insert this new record into another table B.


CREATE TABLE [dbo].[B](
	[MatchID] [nvarchar](100) NULL,
	[MatchCode] [nvarchar](100) NULL,
	[SpecialEventCode] [nvarchar](100) NULL,
	[IncidentID] [nvarchar](100) NULL,
	[Team] [nvarchar](10) NULL,
	[Minute] [nvarchar](10) NULL,
	[Score] [nvarchar](50) NULL,
	[deleteInfo] [nvarchar](10) NULL,
	[Player] [nvarchar](100) NULL
) ON [PRIMARY]


Best Regards.

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 05/30/2013 :  05:28:04  Show Profile  Reply with Quote

CREATE TRIGGER YourriggerName
ON dbo.A
AFTER INSERT
AS
BEGIN 
INSERT dbo.B
SELECT *
FROM INSERTED
END


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000