new sql trick for an old dog
Today at work I rewrote a SQL stored procedure, replacing code which used a cursor with code that does not. I did this because since last week when we upgraded the database engine, this stored procedure has been executing dog-slow. I’d heard that cursors cause a performance hit so I was very happy to see the cursorless version running at least twice as fast as the original.
The new version declares a variable as a table datatype, which acts like an in-memory table. This technique was new to me. So I was very pleased when my work paid off.