sql server 2008 - CURSOR Table Error When Executing: Select statements included within a function cannot return data to a client -
i trying pass 2 values in function using cursor table. correct? modified post earlier. when execute function, executes successfully. unsure how test in sql.
use [pmclw1] go /****** object: userdefinedfunction [dbo].[func_pnms_ca] script date: 08/13/2013 14:41:16 ******/ set ansi_nulls on go set quoted_identifier on go alter function [dbo].[func_pnms_ca](@scrdet_seqid int, @jobseqid int) returns varchar(5000) begin declare @retval varchar(5000), @temp varchar(1000) declare cacur cursor select top 1 isnull (spcops_answer, '') spcops scrdet_seqid = @scrdet_seqid declare cacur cursor select b.jbstat_description jbwork inner join jbstat b on a.jbstat_seqid = b.jbstat_seqid a.prjobs_seqid = @jobseqid , a.dptmnt_seqid=7 open cacur fetch next cacur @temp set @retval = '' while @@fetch_status = 0 begin if len(@retval) = 0 set @retval = @temp else set @retval = @retval + ', ' + @temp fetch next cacur @temp end close cacur deallocate cacur return @retval end
Comments
Post a Comment