USE [FM_Dev]GO/****** 对象: UserDefinedFunction [dbo].[GetClassNameByStudentCode] 脚本日期: 05/23/2014 17:20:43 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO-- =============================================-- Author: -- Create date: 2014年5月7日-- Description: 根据学员编号获取学员报读的班级名称拼接字符串-- =============================================CREATE FUNCTION [dbo].[GetClassNameByStudentCode] ( @StudentCode varchar(50))RETURNS varchar(100)ASBEGIN declare @ClassName nvarchar(200) set @ClassName='' select @ClassName = @ClassName + ClassName + ',' from FM_Class cls join FM_StudentClass sc on sc.ClassCode=cls.ClassCode where sc.code=@StudentCode order by cls.Id if @ClassName<>'' begin select @ClassName = left(@ClassName, len(@ClassName)-1) end return @ClassNameEND
新闻热点
疑难解答