请问我的触发器怎么编译不过?总是提示说“无法绑定由多个部分组成的标识符 "Session.CreateTime"”

wonderful_abc 2011-11-01 03:42:10
CREATE TRIGGER CheckSessionStatus_DELETE
ON [Session]
FOR DELETE
AS
if DateDiff(minute, DateAdd(minute, 20, [Session].CreateTime), getdate()) > 0
delete from [Session] where ID=(select ID from deleted)
...全文
132 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wonderful_abc 2011-12-09
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 fredrickhu 的回复:]
SQL code
if exists(select 1 from [Session] where DateDiff(minute, DateAdd(minute, 20, [Session].CreateTime), getdate()) > 0)
delete from [Session] where ID=(select ID from deleted)
[/Quote]


DateDiff(minute, DateAdd(minute, 20, [Session].CreateTime), getdate()) > 0 不是BOOL值么?
--小F-- 2011-11-01
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 wonderful_abc 的回复:]
可是到目前为止,还不知道为什么会出现这个错误....
[/Quote]
if不能那么用的 IF后面需要跟BOOL值。
--小F-- 2011-11-01
  • 打赏
  • 举报
回复
if exists(select 1 from  [Session] where  DateDiff(minute, DateAdd(minute, 20, [Session].CreateTime), getdate()) > 0)
delete from [Session] where ID=(select ID from deleted)
wonderful_abc 2011-11-01
  • 打赏
  • 举报
回复
可是到目前为止,还不知道为什么会出现这个错误....
wonderful_abc 2011-11-01
  • 打赏
  • 举报
回复
谢谢qianjin036a!
-晴天 2011-11-01
  • 打赏
  • 举报
回复
CREATE TRIGGER CheckSessionStatus_DELETE
ON [Session]
FOR DELETE
AS
delete from [Session]
where DateDiff(minute, DateAdd(minute, 20, [Session].CreateTime), getdate()) > 0
and ID in(select ID from deleted)
xuam 2011-11-01
  • 打赏
  • 举报
回复
delete from [Session] where ID in (select ID from deleted)

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧