Sql: select for update

Luca Manzini 21 Reputation points
2022-03-11T12:31:50.097+00:00

Is it true that in the future you will remove the statement select for update from sqlserver as written below?
Because i need to use it in my application and need to know if i have to find a different solution.

"Article
11/02/2021
2 minutes to read
5 contributors

Important

This feature will be removed in a future version of Windows. Avoid using this feature in new development work and plan to modify applications that currently use this feature. Microsoft recommends using the driver's cursor functionality.

For maximum interoperability, applications should generate result sets that will be updated with a positioned update statement by executing a SELECT FOR UPDATE statement. Although the cursor library does not require this, it is required by most data sources that support positioned update statements.

The cursor library ignores the columns in the FOR UPDATE clause of a SELECT FOR UPDATE statement; it removes this clause before passing the statement to the driver. In the cursor library, the SQL_ATTR_CONCURRENCY statement attribute, along with the restrictions mentioned in the previous section, controls whether the columns in a result set can be updated."

Ty

SQL Server Other
{count} votes

Accepted answer
  1. Seeya Xi-MSFT 16,586 Reputation points
    2022-03-14T03:01:17.84+00:00

    Hi @Luca Manzini ,

    Hope everything goes well.
    I put the related document here for other members to read: https://learn.microsoft.com/en-us/sql/odbc/reference/appendixes/processing-select-for-update-statements?view=sql-server-linux-2017

    Is it true that in the future you will remove the statement select for update from sqlserver as written below?

    Yes, it is. Please note this is a official document.
    The SELECT FOR UPDATE may lock data for a long time and slow down transaction processing.

    Best regards,
    Seeya


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2022-03-11T22:16:58.98+00:00

    I don't know the particulars of SELECT FOR UPDATE, but generally, cursors is something you should avoid, both server-side and client-side.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.