Function Parameter



I am writing a function which will take two parameters. One the field
to be returned from a table and second parameter is the ID of the
record to be returned.

Problem is it's not returning the value of the field specified in the
parameter but instead returns the parameter itself. Is there a
function that will get the parameter to be evaluted first?

ALTER FUNCTION [dbo].[getScholarYearData]
(
-- Add the parameters for the function here
@FieldName varchar(50), @ScholarID int
)
RETURNS varchar(255)
AS
BEGIN
-- Declare the return variable here
DECLARE @ResultVar varchar(255)

-- Add the T-SQL statements to compute the return value here
SELECT @ResultVar=EXECUTE(@FieldName)
FROM dbo.qmaxScholarYearID INNER JOIN
dbo.tblScholarYears ON
dbo.qmaxScholarYearID.ScholarID = dbo.tblScholarYears.ScholarID AND
dbo.qmaxScholarYearID.MaxOfScholarYearID =
dbo.tblScholarYears.ScholarYearID

-- Return the result of the function
RETURN @ResultVar

END

.



Relevant Pages

  • Re: recursive classes
    ... Before writing this post I must declare that this problem is part of a ... The two classes represent entities that have preferences over one ... allowed to express indifference in their preferences; ...
    (comp.lang.java.programmer)
  • Re: How to pass a function address to a COM callback
    ... This COM function interface is ... fixed (the second parameter must be an int32 address of a callback function). ... Minfu ... >>> You should be able to declare the parameter of type MethodInvoker ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: null terminated strings
    ... it is nice to not have to declare such. ... Even a programmer with a poor typewriting does not use that much time typing the code his writes. ... It will take you much longer time finding that bug with a debugger than if it is reported by the compiler. ... I have a hunch that writing and using that utility has taken you a sizable fraction of the time you have save not writing declarations. ...
    (comp.os.vms)
  • Re: XP has no significant bugs other than those of its defenders
    ... What started this was your writing: "I ain't flaming you, ... need to see how viruses work before you can declare every OS to be ...
    (sci.electronics.design)
  • Re: STS51L Accident Questions
    ... I was declared part of the conspiracy to cover up the truth about US ... Gubmint involvement with alien flying saucers after writing an article ... off another discussion forum ... I'm sure someone will declare me to be part of the Great Conspiracy ...
    (sci.space.history)

Loading