3

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.

4

1 回答 1

3

IHMO,没有区别,因为引擎在任何一种情况下都会实例化关于变量的相同内存。编写代码只是很短的时间,但我更喜欢为每个变量使用 DECLARE,因为代码变得更好阅读

于 2013-08-24T10:14:28.883 回答