Click here to Skip to main content
15,867,878 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
****** Script for SelectTopNRows command from SSMS ******/SELECT TOP 1000 [Cust_name]
,[Cust_no]
,[Cust_address]
,[Cust_city]
,[Cust_state]
,[Cust_zip]
,[Cust_cc_type]
,[Cust_email]
FROM [ITCO630_GP3].[dbo].[Customer_Table]

/****** Script for SelectTopNRows command from SSMS ******/
SELECT TOP 1000 [Emp_name]
,[Emp_no]
,[Emp_address]
,[Emp_city]
,[Emp_state]
,[Emp_zip]
,[Emp_payrate]
,[Emp_startdate]
,[Emp_position]
FROM [ITCO630_GP3].[dbo].[Employee_Table]

/****** Script for SelectTopNRows command from SSMS ******/
SELECT TOP 1000 [movie_name]
,[movie_catagory]
,[movie_year]
,[movie_actor]
,[movie_rating]
FROM [ITCO630_GP3].[dbo].[Movie_Table]

/****** Script for SelectTopNRows command from SSMS ******/
SELECT TOP 1000 [Rental_rate_blueray]
,[Rental_rate_dvd]
,[Rental_date]
,[rental_duedate]
FROM [ITCO630_GP3].[dbo].[Rental_Table]
Posted
Comments
_Maxxx_ 19-Jan-14 21:46pm    
You haven't made it clear what you want the trigger to do.

You can't have one trigger that is run for four tables. You could write a user defined function and have four triggers that call it, if you want to centralise your code, but you can't write one trigger that is called based on select statements in four different tables, it does not work that way. In fact, you can't trigger on a select at all ( as nothing actually 'happens', no data is changed ). So, you'd need to write stored procs to do your selects, and you can still centralise your actions in a UDF if you want to make your code easier to maintain.
 
Share this answer
 
v2
Comments
Member 10534461 19-Jan-14 21:32pm    
Can you set it up for me? or give me an example.
Christian Graus 19-Jan-14 21:59pm    
Oh, sorry, I was wrong. You can't trigger on a select, as nothing changes. You can only trigger if your data changes. You'd have to replace your select statements with stored procs that also do what ever it is you want to do at the same time.
Member 10534461 19-Jan-14 22:02pm    
ok, Thanks
SQL
CREATE TRIGGER trgAfterUpdate ON  dbo.tblEmployee
FOR UPDATE
AS

    if update(EmployeeLock)
        insert into tblLog value(put the values here)


GO
 
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