Luis Cazares (1/7/2014)
Sean Lange (1/7/2014)
I am guessing that what you really want is all the rows from the function and values from the table if there is a match?This is where you can turn your join around to a right join.
select *
From mytable a
RIGHT JOIN dbo.udf_Myfunction(a.col1) udf on udf.col = a.col1
Hey Sean,
The parameter from the udf is a column from the table (I guess you didn't notice), so he would need to use APPLY. Even if a JOIN would be possible, RIGHT JOIN would make no sense as it shouldn't return any values not present on the table.
/facepalm
I didn't notice the parameter was from the table.
I figured he wanted the values from the function and nulls when there was no match.
/me slithers away quietly hoping nobody will notice how awful his original suggestion was. 😛
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/