Skip to content

Documentation issue for EnableOptimizedParameterBinding  #2393

@Grauenwolf

Description

@Grauenwolf

If EnableOptimizedParameterBinding is true and you are calling a stored procedure with optional parameters, then the call may behave unexpectedly.

For example, say you stored procedure is

CREATE PROCEDURE dbo.UploadToMaxTest
	@AnsiLimted VarChar(500)  = null,
	@UniLimited NVarChar(1000)  = null,
	@Ansi VarChar(Max)  = null,
	@Uni NVarChar(Max)  = null
AS
[...]

And you want to pass in two parameters.

EXEC dbo.UploadToMaxTest @Ansi = 'AAAA', @Uni = N'UUUU';

If you turn on EnableOptimizedParameterBinding, then the generated SQL is...

EXEC dbo.UploadToMaxTest 'AAAA', N'UUUU';

Which means the wrong parameters will be used.

It should be called out in the documentation that EnableOptimizedParameterBinding is not compatible with missing optional parameters because the parameter names will be missing from the SQL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area\DocumentationUse this for issues that requires changes in public documentations/samples.

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions