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 -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -