我有3张表如下:
action
:ID,注意action_type
:ID,日期,ticket_ID,类型action
:ID,类型,名称每次将新记录插入ticket.Note
时,我都需要将action.date
与action_type.name
和ticket
连接起来。但仅限于某些行为类型。
所以请考虑以下情况:
action
是:0056,someNote action_type
是:001234,06/30/2015 14:00:22,0056,4 #0056
是:004,4,创建我需要ticket.Note
someNote;06-30-2015 create
为incorrect syntax
我尝试了以下代码,但收到CREATE TRIGGER trg_notes
ON action
AFTER INSERT AS
BEGIN
UPDATE ticket
SET
Note =
Note +
';' +
CONVERT(VARCHAR(10),(select date from inserted),110) +
(select
t.name
from
action_type t
LEFT OUTER JOIN inserted i ON i.action = t.ID
WHERE
i.action = t.ID)
where
ticket.ID = inserted.ticket_ID
AND
(inserted.action = 4
OR
inserted.action = 7
OR
inserted.action = 8
OR
inserted.action = 11
OR
inserted.action = 12)
END
错误:
zIndex
答案 0 :(得分:2)
我认为你想要实现的是:
file.txt