av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

通過(guò)SQL Server存儲(chǔ)過(guò)程傳送數(shù)組參數(shù)刪除多條記錄

下面為您介紹的SQL Server刪除方法和一般的SQL Server刪除方法有所不同,該方法實(shí)現(xiàn)的是在SQL Server存儲(chǔ)過(guò)程通過(guò)傳送數(shù)組字符串參數(shù)SQL Server刪除多條記錄(如多選或全選表單中的多選框所獲取的一組數(shù)值刪除 )。

 
 
 
  1. CREATE PROCEDURE DeleteNews   
  2.     @ID nvarchar(500)   
  3. as   
  4.     DECLARE @PointerPrev int   
  5.     DECLARE @PointerCurr int   
  6.     DECLARE @TId int   
  7.     Set @PointerPrev=1   
  8.        
  9.     while (@PointerPrev < LEN(@ID))   
  10.     Begin   
  11.         Set @PointerCurr=CharIndex(',',@ID,@PointerPrev)   
  12.         if(@PointerCurr>0)   
  13.         Begin   
  14.             set @TId=cast(SUBSTRING(@ID,@PointerPrev,@PointerCurr-@PointerPrev) as int)   
  15.             Delete from News where ID=@TID   
  16.             SET @PointerPrev = @PointerCurr+1   
  17.         End   
  18.         else   
  19.             Break   
  20.     End   
  21.     --刪除最后一個(gè),因?yàn)樽詈笠粋€(gè)后面沒有逗號(hào),所以在循環(huán)中跳出,需另外再刪除   
  22.      set @TId=cast(SUBSTRING(@ID,@PointerPrev,LEN(@ID)-@PointerPrev+1) as int)   
  23.      Delete from News where ID=@TID   
  24. GO   
  25.  
  26.  
  27. set ANSI_NULLS ON  
  28. set QUOTED_IDENTIFIER ON  
  29. GO  
  30.  
  31. CREATE PROCEDURE AddInter   
  32.     @userID nvarchar(max),  
  33. @ProjecID int  
  34. as   
  35. begin  
  36.     DECLARE @PointerPrev int   
  37.     DECLARE @PointerCurr int   
  38.     DECLARE @TId int   
  39.     Set @PointerPrev=1   
  40.     begin transaction   
  41.     while (@PointerPrev < LEN(@userID))   
  42.     Begin   
  43.         Set @PointerCurr=CharIndex(',',@userID,@PointerPrev)   
  44.         if(@PointerCurr>0)   
  45.         Begin   
  46.             set @TId=cast(SUBSTRING(@userID,@PointerPrev,@PointerCurr-@PointerPrev) as int)      
  47.             exec AddIntention @TID,@ProjecID,0,2    
  48.             SET @PointerPrev = @PointerCurr+1   
  49.         End   
  50.         else   
  51.             Break   
  52.     End   
  53.     --刪除最后一個(gè),因?yàn)樽詈笠粋€(gè)后面沒有逗號(hào),所以在循環(huán)中跳出,需另外再刪除   
  54.      set @TId=cast(SUBSTRING(@userID,@PointerPrev,LEN(@userID)-@PointerPrev+1) as int)   
  55. exec AddIntention @TID,@ProjecID,0,2  
  56. IF (@@error <> 0)  
  57.    begin     
  58.     ROLLBACK TRANSACTION   
  59.    end  
  60.  
  61. COMMIT TRANSACTION  
  62. Return   
  63. end        
  64. GO  

【編輯推薦】

六種SQL Server刪除重復(fù)行的方法

SQL Server創(chuàng)建表語(yǔ)句介紹

SQL Server創(chuàng)建數(shù)據(jù)庫(kù)的命令

sql server系統(tǒng)表?yè)p壞的解決方法

帶您了解SQL Server游標(biāo)


網(wǎng)頁(yè)名稱:通過(guò)SQL Server存儲(chǔ)過(guò)程傳送數(shù)組參數(shù)刪除多條記錄
文章位置:http://uogjgqi.cn/article/dhieghh.html
掃二維碼與項(xiàng)目經(jīng)理溝通

我們?cè)谖⑿派?4小時(shí)期待你的聲音

解答本文疑問(wèn)/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流