sql函数
函数
ALTER function [dbo].[fn_Rollperiodin] ( @id VARCHAR(100) ) returns VARCHAR(1000) as BEGIN DECLARE @mess VARCHAR(1000) SET @mess='' declare @volumelength VARCHAR(18) DECLARE oprpsn_cursor CURSOR FOR SELECT(convert(decimal(18, 2), isnull(rollperiodin.ep_volumelength, 0))) from ep_rollperiodin AS rollperiodin JOIN ep_roll AS ro ON rollperiodin.ep_roll=ro.ep_RollId WHERE ro.ep_RollId= @id OPEN oprpsn_cursor FETCH NEXT FROM oprpsn_cursor INTO @volumelength WHILE @@FETCH_STATUS = 0 BEGIN SET @mess=@mess+@volumelength+',' FETCH NEXT FROM oprpsn_cursor INTO @volumelength END CLOSE oprpsn_cursor DEALLOCATE oprpsn_cursor if len(@mess)>0 set @mess=left(@mess,len(@mess)-1) RETURN @mess END