Go4Expert

Go4Expert (http://www.go4expert.com/)
-   SQL Server (http://www.go4expert.com/forums/sql-server-forum/)
-   -   triggers (http://www.go4expert.com/forums/triggers-t1477/)

isa 27Sep2006 10:13

triggers
 
Hello everyone,

i m using SqlServer 2000 and i have 2 tables :

The 1st Table is : "UserActivityLog": (With following column names)
SessionID
UserActivityCode
LogUserTypeID
SystemUserID
BuyerID
SupplierID
AccessInterfaceID
CallerID
IPAddress

The 2nd Table is : "SessionOnline" (With following column names)
StartDate
LastActivityTime
SessionID
UserActivityCode
LogUserTypeID
SystemUserID
BuyerID
SupplierID
AccessInterfaceID
CallerID
IPAddress

now i want to write a Trigger (Before), After insertion in the first table the inserted values
automatically goes to the 2nd table."SessionOnline" but for the specific SessionID.
e.g. if i make some new insertion in table 1 and write sessionID =1 for 1st insertion after insertion , i make
new insertion again in the table1 and for the same sessionID =1 then my 2nd table updates with the new
one entry.

As for 1st table i made 3 insertion for sessionID=1 then in my 2nd table the last inserted value goes to the 2nd
table. (Each time my 2nd table Updated if i make new insertion for the same sessionID) coz in 2nd table
for each sessionID i have only one entry in the 2nd Table "SessionOnline".


plz reply me asap
its very urgent.plzzzzzzzzz

shabbir 27Sep2006 10:26

Re: triggers
 
Refer to Audit Trail in SQL Server 2000 or SQL Server 7. It creates a trigger for update and delete but it shall gets you moving for the inserts as well.


All times are GMT +5.5. The time now is 07:46.