sql日期函数

ncist_jianeng 2011-06-17 10:30:38
有两个属性续借和日期,要建个触发器,当修该续借时就将日期的月数佳二。。


可以实现吗?怎么实现啊。。
...全文
120 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
sgang81plus 2011-06-17
  • 打赏
  • 举报
回复
CREATE TRIGGER OnUpdate ON 表名
FOR UPDATE AS
IF UPDATE(续借)
BEGIN
UPDATE 表名 set 日期 = DATEADD(mm, 2, 日期) where ...
END
kingtiy 2011-06-17
  • 打赏
  • 举报
回复
最好不要用触发器,写个过程吧.
hehuicong 2011-06-17
  • 打赏
  • 举报
回复
create trigger triggername on tb
for update
as
if update(续借)
begin
update t1
set t1.日期=dateadd(month,2,t1.日期)
from tb t1,inserted t2
where t1.id=t2.id
end

X_0 2011-06-17
  • 打赏
  • 举报
回复

create trigger triggername on tb
for update
as
if update(续借)
begin
update t1
set t1.日期=dateadd(month,2,t1.日期)
from tb t1,inserted t2
where t1.id=t2.id
end
Mr_Nice 2011-06-17
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zy112429 的回复:]

用计算列吧。
[/Quote]

同意

GoAwayZ 2011-06-17
  • 打赏
  • 举报
回复
用计算列吧。

22,209

社区成员

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

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