Domanda

I am performing a SQL query similar to the following

SELECT fn.FullName, pn.LastName, pn.FirstName, pn.MI
FROM Source.dbo.tblPerson fn
    cross apply dbo.ParseFullName(fn.FullName) pn

the result looks fine for the first 85 rows the 86th+ always have NULL for columns derived from the UDF. If I add a where or order by clause to change the result set, it is always the first 85 rows that return the complete set of results. because the 85 number is so consistent, I am thinking that it is something that I am overlooking.

Any help that anyone can provide would be great

È stato utile?

Soluzione 2

I figured out what the problem was. The UDF that was being called, as per the example, dbo.ParseFullName was call OLE Automation objects. Apparently, I was not properly destroying the objects via sp_OADestroy. I was destroying the initial object but not the all of the derived objects. Once I resolved that issue at the end of the UDF, I starting getting all of the results as expected. Thanks for all of the help.

Altri suggerimenti

Try replacing cross apply with outer apply. Make sure that your Sql won't bug out on the NULL.

SELECT fn.FullName, pn.LastName, pn.FirstName, pn.MI
FROM Source.dbo.tblPerson fn
OUTER APPLY dbo.ParseFullName(fn.FullName) pn
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top