2

In a SQL Server stored procedure, if we declare a local variable and assign the value by calling a scalar function DECLARE @variable_name INT= dbo.scalarfuntion_name(@p1, @p2). Would it have any impact on overall performance of SP as in general using scalar function directly into script has performance downgrade most of the times? Thanks!

Michael Green
25.3k13 gold badges54 silver badges100 bronze badges
asked Jan 16, 2020 at 10:14

1 Answer 1

2

Two big problems with using functions in a query are that cardinalities are not accurate and that the function code is called once per row. When setting a variable neither of these are a concern. So I would think, generally speaking, there would be no measurable performance impact.

answered Jan 16, 2020 at 10:22
1
  • OK..Thanks Michael! Commented Jan 16, 2020 at 10:23

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.