-
User Defined Functions in SQL 2k
I expected that a parameter in the new udf's could be used dynamically. However, I am finding out that mabey they can't.
For instance:
Select * from udf_GetElection(2001,1234,1,''
will return the election of person 1234 made in the year 2001 for plan1.
however if i only want one value from the table and want to include the function as a return field in a select, select errors out.
ie:
select top 10 ee.num,lname,fname,ssn, (SELECT optionid FROM UDF_GETELECTION(2001,7126,1,'') as medoc
from employee ee
gives me:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'ee'.
Yet a nested select which is what the udf really is works like this:
select top 10 num,lname,fname,ssn, (SELECT optionid FROM election where planyear =2001 and num = ee.num and planid =1 and electstatus = 'C' as medoc
from employee ee
returns valid data
Is there something I don't understand?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|