ASP.net , C#, and VB.net , and Java, and SQL

coding and testing

博客园 首页 新随笔 联系 订阅 管理

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

posted on 2010-06-04 09:09  mr liao  阅读(134)  评论(0编辑  收藏  举报