Fastest way to determine if record exists

前端 未结 11 1183
清歌不尽
清歌不尽 2020-11-29 16:16

As the title suggests... I\'m trying to figure out the fastest way with the least overhead to determine if a record exists in a table or not.

Sample query:

11条回答
  •  半阙折子戏
    2020-11-29 17:02

    I've used this in the past and it doesn't require a full table scan to see if something exists. It's super fast...

    UPDATE TableName SET column=value WHERE column=value
    IF @@ROWCOUNT=0
    BEGIN
         --Do work
    END             
    

提交回复
热议问题