sql server - T-SQL 1=1 Performance Hit -


For my SQL queries, I usually do the following for the selection statement:

 < Code> SELECT. .. from table where 1 = 1 and T. [Column1] = @tur1 and t. [Column2] = @ the ultimate 2  

If I need to add / delete it will make it easier

Additional information:

Additional information:

/ Strong>

Examples for sheep communicators and others who do not use.

Suppose that the above query, I need to change Perpet 1 which can not be included in the query:

with 1 = 1:

  ... WHERE 1 = 1 & lt; - No change - and T. [Column1] = @ param1 & lt; - changed and t [Column2] = @ Ultimate 2 & lt; - No changes ...  

without 1 = 1:

  ... WHERE and lieutenant; - No change - [column1] = @ param1 & lt; - changed {and removed} t. [Column2] = @ Ultimate 2 & lt; - Change ...  

It seems that if you use the profiler And look, you will end by seeing that the Optimizer will ignore that time otherwise, in the grand scheme of things, there will probably not be much in the way of performance gain or loss.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -