The topic describes the DF036 T-SQL code analysis rule.
BEST PRACTICE
Consider using a table variable instead of a temporary table.
It is recommended to use a table variable instead of a temporary table. Table variables are easier to work with, more secure, and cause fewer recompilations.
Table variables are easier to work with, as they behave similarly to regular tables and do not require explicit dropping after use. They are also considered more secure, as their scope is limited to the current session, reducing the risk of conflicts or data leakage. Additionally, using table variables can lead to fewer recompilations compared to temporary tables, resulting in better query performance.
CREATE TABLE #ids (id INT NOT NULL);
DECLARE @ids TABLE (id INT NOT NULL);