Is there any difference using one DECLARE statement for declaring all your variables in store procedure or function instead of using the statement for each one.

For example:

DECLARE @INST1 INT 
       ,@INST2 BIGINT
       ,@INST3 DATETIME
       .......
       ,@INSTN INT

and

DECLARE @INST1 INT
DECLARE @INST2 BIGINT
DECLARE @INST3 DATETIME
..................
DECLARE @INSTN INT

I am asking for differences like performance, reducing SQL server caches size and other internal for the server stuff, that I am not familiar with and can make the server job easier.

有帮助吗?

解决方案

IHMO, there's no difference because the engine instantiate the same memory about variables in either cases. Is only a short ay to write code, but I prefer using a DECLARE for each variable because the code becomes read better

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top