Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
id plan_id name status
1 1 1A 1
2 1 2A 1
3 1 3A 1 (table 1)
4 2 1A 1
5 2 2A 1
6 2 3A 1
--------------------------------------------

id plan_id date
1 1 12/03/2012 (table 2)
2 2 13/03/2012


i want to add rows in table 1 whenever i add new plan_id in tale 2. pls help me how to do it..
Posted
Comments
Photon_ 15-Mar-12 7:20am    
Create Trigger
Nilesh Patil Kolhapur 15-Mar-12 7:44am    
it is possible but i will get only id and planid k and what about name and status?

add a trigger on table 2 which will insert a row in table 1

XML
CREATE TRIGGER <Schema_Name, sysname, Schema_Name>.<Trigger_Name, sysname, Trigger_Name>
   ON  <Schema_Name, sysname, Schema_Name>.<Table_Name, sysname, Table_Name>
   AFTER <Data_Modification_Statements, , INSERT>
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for trigger here

END
 
Share this answer
 
v2
Create Triggers that will solve your problem
All the best
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900