Hey Guys, I hope that you are enjoying with my blogs writing and today's we will cover some "SQL SERVER" Concepts.
Microsoft SQL Server is a relational database management system, or RDBMS, developed and marketed by Microsoft.
As a database server, it is a software products with primary function of storing and retrieving data as requested by other software application.
Initial Releases is April 24, 1989;
Q. Explain what is a Identity column ?
- Identity Column means its increase the indexing automatically in SQL.
- For Example: Below has given a table which Id has autoincrement.To Implement this Settings go to Column properties -> Indentity Specification->Double click on that->Double click on Is Identity
- Q. Are Nulls allowed in Foreign Keys ?
- Yes, it can be null or duplicate. A foreign key containing null values cannot match the values of a parent key. However, a null foreign key value is always valid, regardless of the value of any of its non-null parts.
- For ExampleAbove has mentioned if we will give null value to foreign key then it will be ok.
- In Database design, a composite key is a candidate key that consist of two or more attributes ( table columns) that together uniquely identify an entity occurrence(table row).
- For Example: I have created a table name" tblCustomer2".
- In that we have taken more than two Primary key which is also known as Composite key. We have taken Id and FirstName as a Primary key.
- The Where clause is used to filter records.
- Its filter those records which fulfil conditions.
- Syntax:
from table_name
where condition;
- Example: select * from tblCustomer1
- But in case of Where Clause it gives particular record.
Note: Its not only used in SELECT statement, its also used in UPDATE, DELETE etc.
Q. How to select Specific columns in select?
- To write Specific columns in select
where Id;"
Q. What is an ALIASES in SQL ?
- It is often used to make column names more readable.
- It is created with As Keyword.
- Syntax: For Column
from table_name;
For Row
select column_name(s)
from table_name AS alias_name ;
Q. Explain the difference between inner vs left vs right ?
- INNER JOIN: INNER JOIN keywords just select records that have matching values in both tables like
- Syntax:
from table1
inner join table2
on table1.column_name=
table.column_name;
- For Example:
cust.Id,
cust.FirstName,
cust.LastName,
address.Address
from tblCustomer1 as cust
inner join tblAddress1 as address
on cust.Id=address.Customer_fk
- LEFT JOIN: LEFT JOIN keyword returns all records from the left table(table1), and the matching record table from right table.
Example:
select cust.Id,
cust.FirstName,
cust.LastName,
address.Address
from tblCustomer1 as cust
left join tblAddress1 as address
on cust.Id=address.Customer_fk
- RIGHT JOIN: RIGHT JOIN keyword returns all records from the right table(table2), and the matching record table from left table.
Example
select
cust.Id,
cust.FirstName,
cust.LastName,
address.Address
from tblCustomer1 as cust
right join tblAddress1 as address
on cust.Id=address.Customer_fk
cust.Id,
cust.FirstName,
cust.LastName,
address.Address
from tblCustomer1 as cust
right join tblAddress1 as address
on cust.Id=address.Customer_fk
Thank You...
No comments:
Post a Comment