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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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
 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
737 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  
 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 2.33 seconds. Powered By: Snitz Forums 2000