hii.. all
i want to use trigger in sql server using asp .net c#.. my stored procedure update data in 2 tables using inner join.. i want to store this updated data in one table (i create a table (UPDATE_LOG)with both table parameters)..my table name is passed using like this for update in database tables
SET @ChildTblName = '[' + @DistrictID + 'Child_D' + ']'
SET @FamilyTblName = '[' + @DistrictID + 'Family_D' + ']'
how to use trigger in both tables that should store updated field in UPDATE_LOG and also update the data in main database tables..
my sp is updating the database tables correctly..bt i want to store updated data in (UPDATE_LOG) table..
plz help..
my trigger code is that use the
UPDATE_LOG
table
USE [SCJ]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[UPDATEINFO_trggr] ON [dbo].[CHLDINFO_LOG]
FOR UPDATE
AS
declare @DistrictID VARCHAR(250),
@barcode VARCHAR(50),
@distic Nvarchar(50),
@block Nvarchar(50),
@GP Nvarchar(50),
@village Nvarchar(50),
@habitation Nvarchar(50),
@location Nvarchar(50),
@residing Nvarchar(50),
@mother_ton Nvarchar(50),
@Pincode Nvarchar(50),
@House_no Nvarchar(50),
@Father Nvarchar(50),
@Mother Nvarchar(50),
@Guardian Nvarchar(50),
@social_grp Nvarchar(50),
@Minority Nvarchar(50),
@Male Nvarchar(50),
@Female Nvarchar(50),
@seasnal_mgrtn Nvarchar(50),
@Mgrtn_Type Nvarchar(50),
@durtn_Mgrtn Nvarchar(50),
@LP Nvarchar(50),
@UP Nvarchar(50),
@SEC Nvarchar(50),
@Ctchmnt_LP Nvarchar(50),
@Ctchmnt_UP Nvarchar(50),
@Ctchmnt_SEC Nvarchar(50),
@Chld_Name NVARCHAR(50),
@SEX Nvarchar(50),
@DOB Nvarchar(50),
@Disblty_type Nvarchar(50),
@Schl_CODE Nvarchar(50),
@CLASS Nvarchar(50),
@NEREASON Nvarchar(50),
@DRPOUT_rsn Nvarchar(50),
@HIGH_class Nvarchar(50),
@LOG_Timestamp datetime
select @Mother=i.Mother from inserted i;
select @Chld_Name=i.Chld_Name from inserted i;
insert INTO CHLDINFO_LOG (DistrictID
,barcode
,distic
,block
,GP
,village
,habitation
,location
,residing
,mother_ton
,Pincode
,House_no
,Father
,Mother
,Guardian
,social_grp
,Minority
,Male
,Female
,seasnal_mgrtn
,Mgrtn_Type
,durtn_Mgrtn
,LP
,UP
,SEC
,Ctchmnt_LP
,Ctchmnt_UP
,Ctchmnt_SEC
,Chld_Name
,SEX
,DOB
,Disblty_type
,Schl_CODE
,CLASS
,NEREASON
,DRPOUT_rsn
,HIGH_class
,LOG_Timestamp)
values (@DistrictID,
@barcode
,@distic
,@block
,@GP
,@village
,@habitation
,@location
,@residing
,@mother_ton
,@Pincode
,@House_no
,@Father
,@Mother
,@Guardian
,@social_grp
,@Minority
,@Male
,@Female
,@seasnal_mgrtn
,@Mgrtn_Type
,@durtn_Mgrtn
,@LP
,@UP
,@SEC
,@Ctchmnt_LP
,@Ctchmnt_UP
,@Ctchmnt_SEC
,@Chld_Name
,@SEX
,@DOB
,@Disblty_type
,@Schl_CODE
,@CLASS
,@NEREASON
,@DRPOUT_rsn
,@HIGH_class
,getdate());
PRINT 'AFTER UPDATE trigger fired.'