What is an Inner join?
The join that displays only the rows that have a match in both the joined tables is known as inner join.
What is an Equi join?
Equi join is a special type of join in which we use only equality operator. Hence, when you make a query for join using equality operator, then that join query comes under Equi join.
Equi join has only (=) operator in join condition.
Equi join can be inner join, left outer join, right outer join.
What is a Left Outer join?
Left join displays all the rows from the first table and matched rows from second table like that.
What is a Right outer join?
Right outer join displays all the rows of second table and matched rows from first table.
What is a Full outer join?
Full outer join returns all the rows from both tables whether it has been matched or not.
What is a Cross Join?
A cross join that produces Cartesian product of the tables that are involved in the join. The size of a Cartesian product is the number of the rows in the first table multiplied by the number of rows in the second table.
What is a Self join?
Joining the table itself called self join. Self join is used to retrieve the records having some relation or similarity with other records in the same table. Here, we need to use aliases for the same table to set a self join between single table and retrieve records satisfying the condition in where clause
What is the difference between cross join and Full outer join?
- It produces the Cartesian product.
- Results in Cartesian product of two tables.
- Results in pairs of rows.
- No join conditions are specified.
Full Outer Join:
- It includes all the rows from both the tables.
- Assigns NULL for unmatched fields.
- Results in every row from both of the tables , at least once.
- A combination of both left and right outer joins.
What is the difference between Temp table and Common table Expression (CTE)?
What is the difference between Temp table and Table Variable?
What is the difference between Local and Global Temp Table?
There are two types of temporary tables: local and global. Local temporary tables are visible only to their creators during the same connection to an instance of SQL Server as when the tables were first created or referenced. Local temporary tables are deleted after the user disconnects from the instance of SQL Server. Global temporary tables are visible to any user and any connection after they are created, and are deleted when all users that are referencing the table disconnect from the instance of SQL Server.
How to execute Large SQL Script File by using SQLCmd?
sqlcmd -S [servername] -d [databasename] -i [scriptfilename]
What is ASCII method?
ASCII will return the ascii value of the character expression.
Would do you please write syntax of table variable?
DECLARE @TableVariabl Table (ID INT, Name VARCHAR(150))
How do we unlock particular user in SQL Server?
First login with system admin user and execute below ALTER command.
ALTER LOGIN login_name WITH password=’password’ unlock;
What is the performance difference between EXISTS and IN?
EXISTS is efficient as if any row returned and it stops the further search.
IN is looking for a specific match which takes longer.
However, they may not always replace each other and we should use as per our system requirements.
Is SQL Case sensitive?
No: SQL is not case sensitive.
What are the different types of cardinality in SQL?
High-cardinality: refers to columns with values that are very uncommon or unique. High-cardinality column values are typically identification numbers, email addresses, or user names. An example of a data table column with high-cardinality would be a USERS table with a column named USER_ID. This column would contain unique values of 1-n. Each time a new user is created in the USERS table, a new number would be created in the USER_ID column to identify them uniquely. Since the values held in the USER_ID column are unique, this column’s cardinality type would be referred to as high-cardinality.
Normal-cardinality: refers to columns with values that are somewhat uncommon. Normal-cardinality column values are typically names, street addresses, or vehicle types. An example of a data table column with normal-cardinality would be a CUSTOMER table with a column named LAST_NAME, containing the last names of customers. While some people have common last names, such as Smith, others have uncommon last names. Therefore, an examination of all of the values held in the LAST_NAME column would show “clumps” of names in some places (e.g. a lot of Smith’s) surrounded on both sides by a long series of unique values. Since there is a variety of possible values held in this column, its cardinality type would be referred to as normal-cardinality.
Low-cardinality: refers to columns with few unique values. Low-cardinality column values are typically status flags, Boolean values, or major classifications such as gender. An example of a data table column with low-cardinality would be a CUSTOMER table with a column named NEW_CUSTOMER. This column would contain only two distinct values: Y or N, denoting whether the customer was new or not. Since there are only two possible values held in this column, its cardinality type would be referred to as low-cardinality.
How to find any Text, Column, Comment, Object Name in SQL Server Objects?
How to Find Missing Number and ID in the SQL Server?