.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

Which one is more optimized: AND, OR, equality operators?

Posted By:      Posted Date: September 30, 2010    Points: 0   Category :Sql Server
A question asked by an SME in an interview:

Which one is more optimized when applying at WHERE clause?

<, >, =, <>, !=, <=, >=




View Complete Post

More Related Resource Links

.NET - Overriding Equals and Equality Operators


Hi ,

Please help me to understand the following code. Iam trying to learn overriding equals method
 in asp.net but couldn't understand. I found this article in a blog. Please explain in detail

public class Employee
     private string employeeId;
     private string lastName;
     private string firstName;
     private DateTime dateOfBirth;
     public string EmployeeId
          get { return employeeId; }
          set { employeeId = value; }
     public string LastName
          get { return lastName; }
          set { lastName = value; }
     public string FirstName
          get { return firstName; }
          set { firstName = value; }
     public DateTime DateOfBirth
          get { return dateOfBirth; }
          set { dateOfBirth = value; }
} // class - Employee
Now, what we need is an easy way to determine if the objects are equal.  
So, we need to override the Equals method. That looks like the following: public override bool Equals(object obj) { // Check for null if(obj == null) return false; // Check for type if(this.GetType() != obj.GetType()) return false; // Cast as Employee Employee employee = (Employee)obj; return (this == empl

Code Optimized Web Development Profile (VS 2010 and .NET 4.0 Series)

When you first run VS 2010 it prompts you to select an IDE profile to use. The profile you select will configure how tool windows are displayed/docked in the IDE by default and set the default keyboard shortcuts. You can then customize any of these settings by using the Tools->Options menu within the IDE and then override/change them. You can also later reset your profile and pick a different one by choosing the Tools->Import and Export Settings menu command.

Optimized Paging and Sorting in ASP.NET GridView

In this article I am going to demonstrate what are the performance drawbacks of using conventional way to page and sort your GridView and then I will demonstrate 'An Optimized way to implement Paging and Sorting'.

Data Points: Standard Query Operators with LINQ


LINQ to Objects and LINQ to Entities have an arsenal of Standard Query Operators that operate on sequences to perform a wide variety of operations.

John Papa

MSDN Magazine March 2008

Advanced Basics: Calling All Operators


This month I found an interesting question in my mailbag. It went something like this: "I am writing some code working with points and other drawing objects in Visual Basic® 2003, and I just want to add an offset to a point, effectively moving the point.

Ken Getz

MSDN Magazine December 2004

AppDomain.Unload effects Unable to evaluate expression because the code is optimized or a native fra

Hello, I create a custom AppDomain.Create().  I registered the Unhandled Exception Event from my custom AppDomain. In the Unhandled Exception Event i try to Unload my AppDomain with AppDomain.Unload. But this effects a "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack." Have anyone a idea what i can do against this behaviour. greetints

Unable to evaluate expression because the code is optimized or a native frame is on top of the call

I have some code that gets the exception Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack. I have pasted some code below. I have confirmed that I am in mixed mode debugging, (native and managed). I have also confirmed that I am not 'pre-compiline' b4 debugging. the code is for a 'csv' download. Can someone help? Response.Clear(); Response.ClearHeaders(); //set the conttent type of the file to be downloaded (IF NEEDED) Response.ContentType = "application/vnd.ms-excel"; // initialize the http content-disposition header to indicate a file attachment with the filename Response.AppendHeader("Content-Disposition", "Attachment; Filename=\"" + strFileNameCSV + "\""); //// transfer the file byte-by-byte to the response object FileInfo fileToDownload = new FileInfo(strFileNameCSV); Response.Flush(); Response.WriteFile(fileToDownload.FullName); Response.End();

Outer join operators *= and =* are not supported in 90 or later compatibility modes Upgrade issue

Hi all In processes of upgrading SQL Server 2000 to SQL Server 2008 I held up with one issue I am not a good pragrammer If some helps me how to modify this query,realy it help for me. "Outer join operators *= and =* are not supported in 90 or later compatibility modes" Here this query SELECT Brnd.Name, Dev.Devype FROM Prd,PrdRel, Rel, RelVer, DevSoft, DevCla, Dev, Brnd,OVer WHERE Prd.ID = PrdRel. Product AND Rel.ID = PrdRel.Release AND RelVer.Release = Rel.ID AND DevSofte.ReleaseVersion = RelVer.ID AND DevSoft.DeviceClass = DevCla.ID AND DevCla.ID = Dev.DeviceClass AND Brnd.ID = Dev.Brand AND OVer.ID =* Dev.OSVersion AND RelVer.Latest = 'Y' AND Prd.ID = @Product AND Rel.OS IN (@OS) Please some help me how to code  to come out from the problem. your help going to be greate for me.  SNIVAS

How to convert varchar to = , > and < operators

I have a procedure like

create procedure emp_fill(@operator1 varchar, @operator2 varchar, @emp_salary int, @emp_comm int)
select * from employees where salary [>|=|<] @emp_salary and commission_pct [>|=|<] @emp_comm;

Now the problem is I am sending @operator1 and @operator2 parameter in this procedure either '>' or '=' or '<'
But I cannot write select * from employees where salary @operator1 @emp_salary and commission_pct @operator2 @emp_comm;

What I have to do to convert @operator1 and @operator2 which are varchar type, to change them as [>|=|<] operators and use them in the procedure.

pls help

What is the Best and most optimized,Scalable architecture to follow for developing Medium sized ASP.


Dear All

I am working on ASP.Net for well over 3 years now and during that time span i have used several different architectures / designs.

I have been assigned a medium sized application for development and i want to use the best architecture for it which is easily scalable. flexible, fast in performance and easy to manage changes in application.

In my last project i used Silverlight ,RIA,LINQ combo and although it worked out pretty well but i must say my thrust for designing the most optimistic architecture is far from being satisfied.

Now , iam planing to use MVC 2 with web forms and LINQ, is that a good idea?

Which new tools should i start off with?

How many tiers should i create in my application?always used 3 tier previously.

Now, i know an application architecture depends upon the application it self and its size.but surely  we can make some building blocks or a started kit which could be used in any application regardless of size.

Thanks alot


What components of a RegEx Pattern need to be deleted to cancel the appending of Math Operators to t


The following RegEx Pattern ID's Constants in Excel Formulas.  In addition, the Pattern appends the Operator (which actually preceeds the Constants in the Excel Formula) to the Constants and I would like the Operator to disappear as prepended of appended.

Possible candidates for deletion are: >>>>                  [^-+*/^<>=]+    [-+*/^<>]

Dim Pattern As String = "(-?(('[\s\S]*?'!\w+)|(\([\s\S]*?\))|([^-+*/^<>=]+)))([-+*/^<>][<>=]?|$)"

That said, in case I need a revised prepending-pattern in the future, I would like two solutions (Match Patterns) :

1) No Operators appended or Prepended at all (Constants only)


2) Operators (which precede the Constants in Excel Formulas) Prepended to the Constants


Thanks! Dennis

List Validation Boolean AND OR operators


I need to make a validation that requires two separate tests and both must pass, therefore an AND operator is needed to concantenate the two results.  However, from what I can see the List Validation syntax does not support this.  Any ideas?

optimized query


I work with SQL 2008. So I have two tables:

Product(maker, model, type);Printer(code, model, color, type, price). "Model" is a foreign key for Printer. "Color" in table Printer may be "y" or "n". So I need Find the makers of the cheapest color printers. Result set: maker, price.

My query is:

select P.maker, Pr.price from printer pr
left join product p on p.model = pr.model
where pr.color='y' and pr.price=(select min (price) from Printer where color = 'y')

But the compiler writes me something like that:

Your query produced correct result set on main database, but it failed test on second, checking database.
* Wrong number of records (more by 2)
This exercise has FAQ

What can I do with my query? What

Bulk insert with optimized way



I have a problem  -- One of my page demand bulk insert and bulk update with optimized way.

so let me know How this bulk insertation possible with optimized way and its highly appreciated if give some sample.






sys.dm_db_missing_index_details - equality and inequality columns



I was reading about this DMV sys.dm_db_missing_index_details. It has two columns equality_columns and inequality_columns. The description of these columns is given at http://msdn.microsoft.com/en-us/library/ms345434.aspx

Actually I am not able to understand it clearly that what it means when it says equality or inequality predicates. Could someone please clarify with an example?


In persuit of learning SQL.

Optimized way of comparing XML Nodes

Hi Guys, I have an requirement which is already implemented in what seems to be an inefficient way. I have an XML Content and all the nodelist will always have the same set of attributes. <root> <data id ='1' name="ABC" groupId="45" referenceID="2345" status="old"> <data id ='2' name="XYZ" groupId="145" referenceID="5245" status="old"> <data id ='1' name="ABC" groupId="45" referenceID="2344" status="new"> <data id ='2' name="XYZ" groupId="45" referenceID="5245" status="new"> <root> Now I need to check the difference of attributes of "old" node with the "new" nodes. In the above case, the 1st node(status:old) and the 3rd node(status:new) the difference in attributes are ID - nodiff, name - nodiff, groupId - nodiff, referenceID - Different This is implemented in a nested loop and takes a long time to complete the comparison. Is there any other way in which I can achieve the requirement in an efficient way? Thanks Arun
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend