开发者

SQL Server 2008 , SQL Server 2005 [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜