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)
 Using Trigger
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

karthikeyan2004k
Starting Member

India
5 Posts

Posted - 08/26/2014 :  05:00:10  Show Profile  Reply with Quote
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

India
656 Posts

Posted - 08/26/2014 :  05:13:29  Show Profile  Send ahmeds08 a Yahoo! Message  Reply with Quote
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

Edited by - ahmeds08 on 08/26/2014 05:15:28
Go to Top of Page

karthikeyan2004k
Starting Member

India
5 Posts

Posted - 08/26/2014 :  05:22:15  Show Profile  Reply with Quote
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
  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