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