自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

SQL自定義函數(shù)調(diào)用實例

數(shù)據(jù)庫 SQL Server
下文將以實例的方式為您介紹SQL自定義函數(shù)的調(diào)用方法,供您參考,如果您對SQL中的自定義函數(shù)方面感興趣的話,不妨一看。

SQL自定義函數(shù)是SQL函數(shù)中用途最廣的函數(shù)之一,下面就將為您介紹如何調(diào)用SQL自定義函數(shù),供您參考,希望對您有所啟迪。

  1. --根據(jù)組織,崗位和檔案ID返回該用戶可見的日報列表  
  2.  
  3. ALTER proc dbo.GetDailyList @orgid int,@postid int,@ArchivesID int  
  4. as  
  5.     declare @a table(orgid int)  
  6.     insert @a select orgid from organize where orgid = @orgid  
  7.     while @@rowcount > 0   --中間有一遞歸,有點難懂啊  
  8.         insert @a select a.orgid from organize as a inner join @a as b  
  9.         on a.fatherorgid = b.orgid and a.orgid not in(select orgid from @a)  
  10.  
  11.     declare @b table(postid int)  
  12.     insert @b select postid from post where postid = @postid  
  13.     while @@rowcount > 0  
  14.         insert @b select a.postid from post as a inner join @b as b  
  15.         on a.fatherpostid = b.postid and a.postid not in(select postid from @b)  
  16.  
  17. --declare @ArchivesID nvarchar(20)  
  18. --select @ArchivesIDArchivesID=ArchivesID from Users where UserID=@userid  
  19. --print @ArchivesID  
  20.  
  21.  
  22. SELECT a.DailyID, a.TaskTitle,a.AuthorID,b.Name as AuthorName,a.DispathchManID,  
  23.         dbo.GetArchivesNameStr(a.DispathchManID,',') AS DispatchManName,   
  24.         a.AddDate, a.hit,dbo.GetCommentCount(a.DailyID) AS commentcount,  
  25.         'StateStr'=case   
  26.                     when a.StateID=1 then '未執(zhí)行'  
  27.                     when a.StateID=2 then '執(zhí)行中'  
  28.                     when a.StateID=3 then '執(zhí)行完成'  
  29.                 end,  
  30.         'ImportTypeName'=case   
  31.                     when a.ImportTypeID=1 then '普通'  
  32.                     when a.ImportTypeID=2 then '緊急'  
  33.                     when a.ImportTypeID=3 then '非常緊急'  
  34.                 end, dbo.GetArchivesNameStr(FinishManID,',') as FinishManName,  
  35.                 dbo.GetArchivesNameStr(FactDispatchManID,',') as FactDispatchManName  
  36. FROM DailyList a LEFT  JOIN  Archives b on a.AuthorID=b.ArchivesID   
  37. WHERE (a.DailyType = 1) AND   
  38.     b.orgid IN (select orgid from @a) and   
  39.     ','+a.DispathchManID like '%,'+convert(nvarchar,@ArchivesID)+',%' 

 

 

 

【編輯推薦】

SQL自定義函數(shù)實例

初級sql select語法

sql server死鎖的檢測方法

SQL SERVER字段類型的說明

SQL Server安全解析

責任編輯:段燃 來源: 互聯(lián)網(wǎng)
相關推薦

2010-09-14 16:47:23

SQL自定義函數(shù)

2010-09-06 15:41:34

SQL函數(shù)存儲過程

2010-10-25 16:05:07

oracle自定義函數(shù)

2011-06-20 16:03:03

Qt 控件 鼠標

2010-06-28 11:00:46

SQL Server

2013-01-09 17:22:38

Android開發(fā)Camera

2018-03-16 08:41:16

Oracle存儲函數(shù)

2010-10-20 16:07:48

SQL用戶自定義角色

2022-10-09 08:35:06

SQL自定義排序

2010-05-11 13:16:21

Unix awk

2022-04-01 15:59:22

SQLPostgreSQL審計

2010-07-09 14:30:56

SQL Server

2011-04-19 10:33:16

ASP.NET自定義控

2024-02-20 08:01:08

SQL注入器MyBatis數(shù)據(jù)庫

2010-09-09 11:55:36

SQL函數(shù)標簽

2021-07-15 16:41:21

Swift查詢函數(shù)

2023-10-31 09:10:39

2009-08-12 14:53:50

C#類型轉(zhuǎn)換函數(shù)

2010-07-20 08:48:14

SQL Server

2015-02-12 15:33:43

微信SDK
點贊
收藏

51CTO技術(shù)棧公眾號