1

I am using SQL Server 2012. I know that with stored procedures you can pass arguments by name.

EXEC PROC_A @p_para = 'Test'

Can one do the same with a function?

SET @iID = [dbo].[FUNC_GET_INTEGRITY_ID](@p_strSearchForValue = '805-2020', @p_strSearchForValue2 = DEFAULT, @p_tinProcessID = 1, @p_bitRunStatic = 1) 

If this is not the correct syntax, what is it or is there another way to do this.

Would be nice to see the named parameters as a form of self documentation.

2

1 Answer 1

3

Here is the correct syntax for executing the function by named parameters (see Arulkumar's comment link above for details).

EXEC @iID = [dbo].[FUNC_GET_INTEGRITY_ID] @p_strSearchForValue = '805-2000', @p_strSearchForValue2 = DEFAULT, @p_tinProcessID = 1, @p_bitRunStatic = 1 

Note that there are no brackets used as would be in a SET or SELECT statement.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.