SQL Server 2008 , SQL Server 2005 [closed]
I am working with a database name xyz , table name a ,b, c, d. my question is if in table a name field , table b 开发者_如何学Python email field, table c phone number , change/update I want to make table d field upload to 1.
These tables has many fields, but I only want to change table d field when given three field change in three different table.
If I understand you question correctly, I would add three columns to table d and set each one to 1 in the update trigger of the other tables. Then, in your selects, you can set a virtual column to 1 if all three column are set to 1 in table d.
You need an update trigger on all three tables a
,b
and c
that checks if the relevant value has changed and if so updates the corresponding upload
field in table d
Example for table a
CREATE TRIGGER dbo.YourTrigger
ON a
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
IF NOT UPDATE(name)
RETURN
UPDATE d
set upload = 1
FROM d
JOIN inserted i ON i.join_column = d.join_column
END
精彩评论