Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Using Trigger

Author  Topic 

karthikeyan2004k
Starting Member

5 Posts

Posted - 2014-08-26 : 05:00:10
Using Trigger i want to insert a record from a table with condition(person whose age is >31) to another table
Please let me know the various options for this

Thanks in Advance



karthikeyan.r

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-08-26 : 05:13:29
I am not sure, but can you try this
CREATE TRIGGER
[dbo].[triggername]
ON
[dbo].[yourtable]
FOR INSERT, UPDATE
AS
BEGIN

INSERT INTO yourtable
(
col1,
col2
)
SELECT
value1,
value2 FROM Inserted AS I
where i.age >31

END


Javeed Ahmed
Go to Top of Page

karthikeyan2004k
Starting Member

5 Posts

Posted - 2014-08-26 : 05:22:15
Thanks for Replying
quote:
Originally posted by ahmeds08

I am not sure, but can you try this
CREATE TRIGGER
[dbo].[triggername]
ON
[dbo].[yourtable]
FOR INSERT, UPDATE
AS
BEGIN

INSERT INTO yourtable
(
col1,
col2
)
SELECT
value1,
value2 FROM Inserted AS I
where i.age >31

END


Javeed Ahmed



karthikeyan.R
Go to Top of Page
   

- Advertisement -