SQL Server BasicsWhat is SQL Server database?What is RDBMS?What is Normalization?Why we use Denormalization?What_is_SQL?What is PL/SQL?Difference between SQL and PL/SQLDatabase TableOne to One RelationshipOne to Many RelationshipMany to Many RelationshipMany to One RelationshipString Data TypesNumber Data TypesDate Data TypesOther Data TypesCreate DatabaseDrop DatabaseCreating and Managing Users in SQL ServerCreate TableAlter TableDrop TableConstraints in SQL serverPrimary KeyForeign KeyUnique KeyCandidate KeyComposite KeyDifference between primary key and candidate keyPrimary key and foreign key relationshipSurrogate KeyCascading Referential Integrity ConstraintsSelf Referential Integrity ConstraintsInsert into statementInsert multiple recordsUpdate statementDelete statementTruncate statementDifference between Delete and TruncateAlias in SQL ServerSelect statementSelect DistinctSelect TopSelect IntoNull Functions(ISNULL(),NULLIF(),COALESCE())Sub QueryIdentity ColumnSequence objectDifference between sequence and identity columnSQL Server ClausesWHERE ClauseOrder By ClauseTop N ClauseGroup By ClauseHaving ClauseDifference between Where and HavingSQL Server OperatorsArithmetic OperatorsComparison OperatorsLogical OperatorsBitwise OperatorsAny OperatorsAll OperatorsUnion OperatorsUnion All OperatorsDifference between Union and Union AllIntersect OperatorExcept OperatorDifference between Except and IntersectJoinsInner JoinLeft JoinRight JoinFull JoinSelf JoinCross JoinViewsWhat are views?Create views using SSMSIndexed ViewsComplex ViewsCheck Option in ViewCheck Encryption in ViewSchema Binding Option in ViewRead-only ViewsUpdatable ViewsAdvantages and disadvantages of viewsCreate multiple views on one tableCan we implement index on views?Can we Perform Insert, update, delete operation on views?Stored Procedure and FunctionsWhat are Stored Procedures?Why we use stored procedures?Passing parameters to Stored procedureUser-Defined FunctionsDifference between UDF and Stored procedurePre-Defined Functions@@Indentity and Scope_IndentityNULLIF, ISNULL and COALESCE

SQL - Logical Operators

In SQL Server, logical operators are used to combine multiple conditions or Boolean expressions to form more complex conditions. These operators allow you to perform logical operations on the results of comparisons or conditions. The following logical operators are available in SQL Server:

1-AND: Returns true if both conditions on either side of the operator are true.

Example:


SELECT * FROM Customers WHERE Country = 'USA' AND City = 'New York';

2-OR: Returns true if at least one of the conditions on either side of the operator is true.

Example:


SELECT * FROM Customers WHERE Country = 'USA' OR Country = 'Canada';

3-NOT: Negates the result of a condition or Boolean expression.

Example:


SELECT * FROM Customers WHERE NOT Country = 'USA';

4-EXISTS: Checks if a subquery returns any rows. It is typically used in combination with a correlated subquery.

Example:


SELECT * FROM Orders o WHERE EXISTS (SELECT 1 FROM Customers c WHERE c.CustomerID = o.CustomerID);

5-IN: Checks if a value matches any value in a subquery or a list of values.

Example:


SELECT * FROM Customers WHERE Country IN ('USA', 'Canada', 'Mexico');

6-BETWEEN: Checks if a value is within a specified range.

Example:


SELECT * FROM Products WHERE UnitPrice BETWEEN 10.00 AND 20.00;

7-LIKE: Checks if a string value matches a specified pattern. It is commonly used with wildcard characters (% and _).

Example:


SELECT * FROM Products WHERE ProductName LIKE 'Apple%';

These logical operators can be used in combination with comparison operators, parentheses, and other logical operators to create complex conditions and control the flow of data retrieval in SQL Server. They are commonly used in WHERE clauses, JOIN conditions, and HAVING clauses to filter and manipulate data based on specific logical conditions.