SQL自定义函数调用实例

复制--根据组织,定义调用岗位和档案ID返回该用户可见的免费信息发布网函数日报列表 ALTER proc dbo.GetDailyList @orgid int,@postid int,@ArchivesID int as declare @a table(orgid int) insert @a select orgid from organize where orgid = @orgid while @@rowcount > 0 --中间有一递归,b2b供应网有点难懂啊 insert @a select a.orgid from organize as a inner join @a as b on a.fatherorgid = b.orgid and a.orgid not in(select orgid from @a) declare @b table(postid int) insert @b select postid from post where postid = @postid while @@rowcount > 0 insert @b select a.postid from post as a inner join @b as b on a.fatherpostid = b.postid and a.postid not in(select postid from @b) --declare @ArchivesID nvarchar(20) --select @ArchivesIDArchivesID=ArchivesID from Users where UserID=@userid --print @ArchivesID SELECT a.DailyID,实例 a.TaskTitle,a.AuthorID,b.Name as AuthorName,a.DispathchManID, dbo.GetArchivesNameStr(a.DispathchManID,,) AS DispatchManName, a.AddDate, a.hit,dbo.GetCommentCount(a.DailyID) AS commentcount, StateStr=case when a.StateID=1 then 未执行 when a.StateID=2 then 执行中 when a.StateID=3 then 执行完成 end, ImportTypeName=case when a.ImportTypeID=1 then 普通 when a.ImportTypeID=2 then 紧急 when a.ImportTypeID=3 then 非常紧急 end, dbo.GetArchivesNameStr(FinishManID,,) as FinishManName, dbo.GetArchivesNameStr(FactDispatchManID,,) as FactDispatchManName FROM DailyList a LEFT JOIN Archives b on a.AuthorID=b.ArchivesID WHERE (a.DailyType = 1) AND b.orgid IN (select orgid from @a) and ,+a.DispathchManID like %,+convert(nvarchar,@ArchivesID)+,% 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.高防服务器
本文地址:http://www.bzve.cn/html/418b8099501.html
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。