新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
SQL自定義函數(shù)調(diào)用實例
SQL自定義函數(shù)是SQL函數(shù)中用途最廣的函數(shù)之一,下面就將為您介紹如何調(diào)用SQL自定義函數(shù),供您參考,希望對您有所啟迪。

成都創(chuàng)新互聯(lián)主要為客戶提供服務(wù)項目涵蓋了網(wǎng)頁視覺設(shè)計、VI標(biāo)志設(shè)計、網(wǎng)絡(luò)營銷推廣、網(wǎng)站程序開發(fā)、HTML5響應(yīng)式重慶網(wǎng)站建設(shè)公司、手機(jī)網(wǎng)站制作設(shè)計、微商城、網(wǎng)站托管及成都網(wǎng)站維護(hù)公司、WEB系統(tǒng)開發(fā)、域名注冊、國內(nèi)外服務(wù)器租用、視頻、平面設(shè)計、SEO優(yōu)化排名。設(shè)計、前端、后端三個建站步驟的完善服務(wù)體系。一人跟蹤測試的建站服務(wù)標(biāo)準(zhǔn)。已經(jīng)為門窗定制行業(yè)客戶提供了網(wǎng)站開發(fā)服務(wù)。
- --根據(jù)組織,崗位和檔案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 --中間有一遞歸,有點難懂啊
- 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 '未執(zhí)行'
- when a.StateID=2 then '執(zhí)行中'
- when a.StateID=3 then '執(zhí)行完成'
- 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)+',%'
網(wǎng)頁名稱:SQL自定義函數(shù)調(diào)用實例
本文URL:http://fisionsoft.com.cn/article/cdhosco.html


咨詢
建站咨詢
