Reputation: 30218
I know that there are similar questions floating around (like SQL Filter criteria in join criteria or where clause which is more efficient) but as I remember SQL
functions are special. Maybe? So basically which is more correct/more performant?
SELECT *
FROM [DBOne].[dbo].[SomeData] SD
INNER JOIN [DBTwo].[DBOne].[SomeOtherData_GetALL]() SOD ON SD.[DataID] = SOD.[DataID]
OR
SELECT *
FROM [DBOne].[dbo].[SomeData] SD
WHERE SD.[DataID] IN (SELECT [DataID] FROM [DBTwo].[DBOne].[SomeOtherData_GetALL]())
Upvotes: 0
Views: 85
Reputation: 1999
I usually use WHERE EXISTS instead of joining. See here for an explanation.
Upvotes: 1
Reputation: 1746
Basically it is like asking JOIN
vs SUB QUERY
, if you are concern with the performance, i suggest to use the JOIN
instead of using WHERE IN
clause, you can see the difference of the performance if you use the execution plan of SQL.
To further understand, you can read this post: Join vs. sub-query
Hope this help.
Upvotes: 0