table valued function returns nothing when single column selected

Hi we run std 2008 r2.  I haven't looked at my friend's function closely yet bur he showed me that when he selects from the function with one column and the same where clause he uses on same func with select *, he gets no data under the column he requested.  But when he selects * he gets a single row.

I took a peek and see a bunch of left joins followed by a bunch of outer applies in his func.   I suppose (thinking out load) if anything random like the order of rows returned or sql decisions on how query runs can affect his function, that might explain it.  

I'll post more here as I learn more. 

April 21st, 2015 1:53pm

removing the top 100 clause in the function produces the expected results but we don't know why yet.
Free Windows Admin Tool Kit Click here and download it now
April 21st, 2015 3:52pm

Is there an ORDER BY clause (with and without the TOP 100)?  If there is, is the ORDER BY deterministic? i.e., is a unique ordering guaranteed based on the columns you have in the ORDER BY clause?

If you don't have the ORDER BY clause, or if the order by clause is not deterministic, that would explain the inconsistent behavior.

April 21st, 2015 4:01pm

How are we supposed to do anything without seeing any code? But I assume you know that the SELECT * is not a scalar value (it is a shorthand for a row in a table)  so that it cannot be a parameter by definition. 
Free Windows Admin Tool Kit Click here and download it now
April 21st, 2015 8:43pm

Can you post the code? Thanks.
April 21st, 2015 8:56pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics