自定义函数:
alter function getvalues(@DictCode varchar(20),@ItemKey varchar(50))
returns varchar(50)
as
begin
declare @varlues varchar(50)
set @varlues=(select ItemValue from DictItem where DictCode=@DictCode and ItemKey =@ItemKey )
return @varlues
end
go
执行:
select dbo.getvalues('AidDept','3')
触发器:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER trigger [dst]
on [dbo].[Archives]
after Insert
as
begin
declare @CMCode varchar(20)
select @CMCode=CMCode from Inserted
update Archives set sec_content=sec_content+1 where CMCode=@CMCode and FamilyRelation=0
end