SQL server temporary tables vs cursors

前端 未结 2 726
梦毁少年i
梦毁少年i 2021-02-05 06:55

In SQL Server stored procedures when to use temporary tables and when to use cursors. which is the best option performance wise?

2条回答
  •  你的背包
    2021-02-05 07:30

    Cursors work row-by-row and are extremely poor performers. They can in almost all cases be replaced by better set-based code (not normally temp tables though)

    Temp tables can be fine or bad depending on the data amount and what you are doing with them. They are not generally a replacement for a cursor.

    Suggest you read this: http://wiki.lessthandot.com/index.php/Cursors_and_How_to_Avoid_Them

提交回复
热议问题