zoukankan      html  css  js  c++  java
  • a Simple Cursor Way

    FUNCTION [dbo].[GetLectureNameByLectureID]
    (@ID int)
    RETURNS varchar(256)
    AS
    BEGIN
     -- Declare the return variable here
     DECLARE @selectname varchar(256),@NAME varchar(256);
        
        Declare cursor_selectname cursor for
     -- Add the T-SQL statements to compute the return value here
     SELECT ID From table Where
        ID=@ID;
        Set @selectname ='';

        open cursor_Lecture
     fetch next from cursor_selectname into @NAME
     while (@@FETCH_STATUS <> -1)
     begin
       set @selectname = @selectname + @NAME + ';';
       fetch next from cursor_selectname into @NAME
     end
     Close cursor_selectname 

     DEALLOCATE cursor_Lecture

        -- Return the result of the function
     if (len(@selectname) > 0)
      SET @selectname =(@selectname ,1,len(@selectname )-1)
     RETURN @selectname   
    END

  • 相关阅读:
    多条件复合搜索的实现
    mysql字符集统一
    JS控制彈出窗口
    mysql常用sql
    正则表达式
    航班时间
    1月19日
    1月28日check小爱用
    在么小猫
    大连美发备考
  • 原文地址:https://www.cnblogs.com/sandy_liao/p/1751152.html
Copyright © 2011-2022 走看看