Afternoon,This cannot be this difficult. All I want is a function to return data from a table. I can't used a table function because I need to pass a field value as a parameter. I tried just a plain vanilla function and I get the message Msg 444, Level 16, State 2, Procedure fn_GetJobEndDate, Line 18Select statements included within a function cannot return data to a client.
What a screaming pain. This is the plain function...the one that returns the error:CREATE FUNCTION fn_GetJobEndDate (@custPO varchar(20))RETURNS varcharASBEGIN DECLARE @EndDate datetime; select top 1 Job_Operation.Sched_End from Job_Operation inner join Job on Job_Operation.Job = Job.Job where Job_Operation.Sched_End is not null and Job.Customer_PO = @custPO order by Job_Operation desc RETURN @EndDateENDGO
Can someone please tell me how to go about fixing this? I need this in a select statement so I can't use a stored proc. The select statement would be something like:select fn_GetWorkCenter(Customer_PO)) as Current_WorkCntr,fn_GetJobEndDate(Customer_PO))as scheduled_end_datefrom Backlogwhere Sales_Order = '200763'
Thanks for any help you can provide.Laura