Skip to main content
added [query-performance] to 2412 questions - Shog9 (Id=1924)
Link
replaced http://dba.stackexchange.com/ with https://dba.stackexchange.com/
Source Link

I will also add a WITH SCHEMABINDING to the TVFN so SQL Server can parallelise the plan. While we're on this subject, the using a multi-statement table-valued function is a good idea (Thank you to Paul WhitePaul White), but multi-statement TVFN's always force a serial plan.

I will now try Lennart's answeranswer, in which he suggested using a CTE.

I will also add a WITH SCHEMABINDING to the TVFN so SQL Server can parallelise the plan. While we're on this subject, the using a multi-statement table-valued function is a good idea (Thank you to Paul White), but multi-statement TVFN's always force a serial plan.

I will now try Lennart's answer, in which he suggested using a CTE.

I will also add a WITH SCHEMABINDING to the TVFN so SQL Server can parallelise the plan. While we're on this subject, the using a multi-statement table-valued function is a good idea (Thank you to Paul White), but multi-statement TVFN's always force a serial plan.

I will now try Lennart's answer, in which he suggested using a CTE.

Tweeted twitter.com/StackDBAs/status/728266137742544898
Added an update
Source Link
Serge
  • 542
  • 3
  • 11

Update

Thank you for suggestions thus far. I will add a [Priority] column as suggested in several answers and comments and an ORDER BY clause to ensure I get the top result.

I will also add a WITH SCHEMABINDING to the TVFN so SQL Server can parallelise the plan. While we're on this subject, the using a multi-statement table-valued function is a good idea (Thank you to Paul White), but multi-statement TVFN's always force a serial plan.

I will now try Lennart's answer, in which he suggested using a CTE.

Update

Thank you for suggestions thus far. I will add a [Priority] column as suggested in several answers and comments and an ORDER BY clause to ensure I get the top result.

I will also add a WITH SCHEMABINDING to the TVFN so SQL Server can parallelise the plan. While we're on this subject, the using a multi-statement table-valued function is a good idea (Thank you to Paul White), but multi-statement TVFN's always force a serial plan.

I will now try Lennart's answer, in which he suggested using a CTE.

Added closing parentheses; thanks @ypercubeᵀᴹ
Source Link
Serge
  • 542
  • 3
  • 11
Loading
Source Link
Serge
  • 542
  • 3
  • 11
Loading