Tuesday 26 March 2013

Connecting to a LDAP Server


Once you have downloaded and installed the LDAP Admin Tool, click on the LDAP Admin Tool shortcut to start the application. When the application is started it will look like the following:

  • Click the Create a new Connection link or Click the New Connection button from the main tool bar. The New LDAP Connection wizard opens.
  • Fill out the first wizard page that is displayed as follows:
    1. The “Connection Name” field should contain a unique name for this connection, this can be anything.
    2. The “Hostname” field should contain the address of the system running the directory instance (DNS name or IP Address of the machine. For example localhost or 127.0.0.1).
    3. The “Port” field should contain the port number on which the directory server is listening for client connections. In most cases it is 389 for non SSL connections and 636 for SSL connections. If you want to use SSL, then you will also need to check the “Use SSL/TLS” check box.
    4. The "Base DN" field can be left blank in most cases. However, if you want you can use the "Fetch Base DNs" button to select a base DN from the namingContexts attribute of the root DSE, or you can enter a specific base DN.
    5. To make sure that you entered the information correctly, click on the “Test Connection” button.
    6. If you only intend to browse the data and don't want to make any changes in the server, and if the server is configured to allow unauthenticated access, then you can click the “Finish” button to connect to directory server. However, if the server does not allow anonymous access, or if you may want to make any changes to the data in the server, then you will likely need to provide values for the "Bind DN" and "Password" fields. To enter credentials click the “Next” button.

New Connect connection wizard page 1

    1. To provide values for “Bind DN” and “Password”, first click the “Simple Authentication” radio button, this will enable the fields. Now enter the values and to make sure you typed in the right values click the “Check Credentials” button.
    2. If you want to provide the optional values click the “Next” button to go to third page else click “Finish” to connect to the directory server.

New LDAP connection wizard 2

In the wizard's third page select the additional connection parameter. If you are not sure what they should be just leave them to default and click Finish to connect to directory server.
    1. Derefence Aliases field sets a preference indicating whether or not aliases should be dereferenced, and if so, when
Never - do not dereference aliases
Searching - dereference aliases when searching but not when finding the base
Finding - dereference aliases when finding
Always - dereference aliases when finding the base object and when searching
    1. Entry count Limit should contain the maximum number of search results to return for a search request. 0 means no limit. Default is 1000.
    2. Timeout should contain the maximum time in seconds that the server should spend returning search results. This is a server-enforced limit. The default of 0 means no time limit.
    3. Enable Referrals specifies whether to automatically follow referrals or not. Check the box to follow referrals automatically. Default is true.
    4. To connect to the server on finish check the “Connect now” check box.

New Connection Wizard page 3

Click Finish to connect to directory server.


Unable to Read Schema
While connecting if you get a warning like this, you need to connect to directory server with credentials.

LDAP Connection unable to read schema

There are many ways to provide credentials for connection; the simplest way to provide credentials is to close the connection and click on the Open Connection Button from the tool bar, select the connection and enter the User DN and Password values or click configure and provide User DN and Password in the credentials tab.

LDAP Connection Open Connection



Don’t know the complete User DN to bind with?
  1. Connect to the directory server using anonymous bind (Click Finish on the wizard page 1).
  2. Once you are connected to the server
  3. Select the entry to bind with ..  and select the Rebind using this entry from the right click context menu
  4. Enter the password and click save userDN and Password if you want this userDN and password to be used for future connections.

LDAP Connection - Rebind Connection

NETWORK TOPOLOGY

Network topology

Network topology is the study of the arrangement or mapping of the elements (links, nodes, etc.) of a network, especially the physical (real) and logical (virtual) interconnections between nodes.[1][2] A local area network (LAN) is one example of a network that exhibits both a physical topology and a logical topology. Any given node in the LAN will have one or more links to one or more other nodes in the network and the mapping of these links and nodes onto a graph results in a geometrical shape that determines the physical topology of the network. Likewise, the mapping of the flow of data between the nodes in the network determines the logical topology of the network. The physical and logical topologies might be identical in any particular network but they also may be different.
Any particular network topology is determined only by the graphical mapping of the configuration of physical and/or logical connections between nodes. LAN Network Topology is, therefore, technically a part of graph theory. Distances between nodes, physical interconnections, transmission rates, and/or signal types may differ in two networks and yet their topologies may be identical

MAN CONNECTION
Metropolitan area networks, or MANs, are large computer networks usually spanning a city. They typically use wireless infrastructure or Optical fiber connections to link their sites.

A MAN is optimized for a larger geographical area than a LAN, ranging from several blocks of buildings to entire cities. MANs can also depend on communications channels of moderate-to-high data rates. A MAN might be owned and operated by a single organization, but it usually will be used by many individuals and organizations. MANs might also be owned and operated as public utilities. They will often provide means for internetworking of local networks. Metropolitan area networks can span up to 50km, devices used are modem and wire/cable

Implementation
Some technologies used for this purpose are ATM, FDDI, and SMDS. These older technologies are in the process of being displaced by Ethernet-based MANs (e.g. Metro Ethernet) in most areas. MAN links between LANs have been built without cables using either microwave, radio, or infra-red laser links. Most companies rent or lease circuits from common carriers due to the fact that laying long stretches of cable can be expensive.
DQDB, Distributed Queue Dual Bus, is the Metropolitan Area Network standard for data communication. It is specified in the IEEE 802.6 standard. Using DQDB, networks can be up to 20 miles (30 km) long and operate at speeds of 34 to 155 Mbit/s.
Several notable networks started as MANs, such as the Internet peering points MAE-West, MAE-East, and the Sohonet media network 
 
WAN CONNECTION
Wide area network

Wide Area Network (WAN) is a computer network that covers a broad area (i.e., any network whose communications links cross metropolitan, regional, or national boundaries [1]). In contrast with personal area networks (PANs), local area networks (LANs), campus area networks (CANs), or metropolitan area networks (MANs) which are usually limited to a room, building, campus or specific metropolitan area (e.g., a city) respectively. The largest and most well-known example of a WAN is the Internet.
WANs [a] are used to connect LANs and other types of networks together, so that users and computers in one location can communicate with users and computers in other locations. Many WANs are built for one particular organization and are private. Others, built by Internet service providers, provide connections from an organization's LAN to the Internet. WANs are often built using leased lines. At each end of the leased line, a router connects to the LAN on one side and a hub within the WAN on the other. Leased lines can be very expensive. Instead of using leased lines, WANs can also be built using less costly circuit switching or packet switching methods. Network protocols including TCP/IP deliver transport and addressing functions. Protocols including Packet over SONET/SDH, MPLS, ATM and Frame relay are often used by service providers to deliver the links that are used in WANs. X.25 was an important early WAN protocol, and is often considered to be the "grandfather" of Frame Relay as many of the underlying protocols and functions of X.25 are still in use today (with upgrades) by Frame Relay.
Academic research into wide area networks can be broken down into three areas: Mathematical models, network emulation and network simulation.

ETHERNET

ETHERNET CABLE
About the Cable:You can find bulk supplies of the cable at many computer stores or most electrical or home centers. You want UTP (Unshielded Twisted Pair) Category 5 cable for basic 10/100 functionality. You want CAT 5e for gigabit (1000BaseT) operation and CAT 6 or 7 gives you a measure of future proofing. Bulk cable comes in many types, there are 2 basic categories, solid and braided cable. Braided cable tends to work better in patch applications for desktop use. It is more flexible and resilient than solid cable and easier to work with, but really meant for shorter lengths. Solid cable is meant for longer runs in a fixed position. Plenum rated cable must be used whenever the cable travels through an air circulation space. For example, above a false ceiling or below a raised floor. It may be difficult or impossible to tell from the package what type of cable it is, so peal out an end and investigate.
Here is what the internals of the cable look like:
Internal Cable Structure and Color Coding
Inside the cable, there are 8 color coded wires. These wires are twisted into 4 pairs of wires, each pair has a common color theme. One wire in the pair being a solid or primarily solid colored wire and the other being a primarily white wire with a colored stripe (Sometimes cables won't have any color on the striped wire, the only way to tell which is which is to check which wire it is twisted around). Examples of the naming schemes used are: Orange (alternatively Orange/White) for the solid colored wire and White/Orange for the striped cable. The twists are extremely important. They are there to counteract noise and interference. It is important to wire according to a standard to get proper performance from the cable. The TIA/EIA-568-A specifies two wiring standards for an 8-position modular connector such as RJ45. The two wiring standards, T568A and T568B vary only in the arrangement of the colored pairs. Tom writes to say "...sources suggest using T568A cabling since T568B is the AT&T standard, but the US Government specifies T568A since it matches USOC cabling for pairs 1 & 2, which allows it to work for 1/2 line phones...". Your choice might be determined by the need to match existing wiring, jacks or personal preference, but you should maintain consistency. I've shown both below for straight through cabling and just T568B for cross over cabling.
A local area network (LAN) is a computer network covering a small physical area (Within 1 KM), like a home, office, or small group of buildings, such as a school, or an airport. The defining characteristics of LANs, in contrast to wide-area networks (WANs), include their usually higher data-transfer rates, smaller geographic place, and lack of a need for leased telecommunication lines.

Wireless LAN

A wireless LAN (WLAN) is a wireless local area network that links two or more computers or devices using spread-spectrum or OFDM modulation technology based to enable communication between devices in a limited area. This gives users the mobility to move around within a broad coverage area and still be connected to the network.
For the home user, wireless has become popular due to ease of installation, and location freedom with the gaining popularity of laptops. Public businesses such as coffee shops or malls have begun to offer wireless access to their customers; some are even provided as a free service. Large wireless network projects are being put up in many major cities: New York City, for instance, has begun a pilot program to cover all five boroughs of the city with wireless Internet access.

Magic Tables in SQL Server

Magic Table in SQL Server:
Magic tables are used to put all the deleted and updated rows. We can retrieve the
column values from the deleted rows using the keyword "deleted"

To project the deleted data into the deleted table we will use "output" clause
Below is the sample code to retrieve the deleted data.

Code Snippet

DECLARE @DeletedTable TABLE(DeletedTableID INT, DeletedData VARCHAR(20))

DELETE VENKATOutput
OUTPUT Deleted.KeyID, Deleted.Name INTO @DeletedTable WHERE KeyID > 3
SELECT * FROM @DeletedTable
Similarly, we can retrieve the updated data and old data too using the keyword "Inserted"

Deadlocks in SQL Server

Deadlock occurs if multiple users tried to access the resources holding some resources with them to finish the task. Dead lock can be avoided by using Lock methods in sql server.Locks can be classified in various types like

1. Rowlevel locking,
2. Page level locking,
3. Table level locking.

Row level locking: A specific row in the table will be locked by the user and meantime no one can access those rows.
Page level locking: In this case, we used to lock a particular page which hold 8 KB of data.
Table level lock: Here, entire table will be locked.

Conceptually there are various types of locks like,

Shared lock : The lock is shared by the users. One person can update the data meantime other persons can select the data.
Exclusive lock: No one can access the data until the concerned person releases the lock.

Database Query tuning

To enhance the performance of the queries, we have to tune the queries,

1. Avoid using "select *" instead specify the needed columns in the select clause.

2. Index the frequent usage columns (which are used in the where clause). The index may be clustered or non clustered based on your business functionality.

3. Specify the table using [servername].[databasename].[owner or schema name].[table name] (This can be priorly used in the transactions involving huge number of tables and huge number of databases.

4. Avoid using cursors in looping the table rows which will make a server roundtrip for each row. Instead, you can opt while loop (transfer the data to temp tables).

5. Avoid using more temporary tables instead you can use table variables.

6. Use set nocount on in the start of your stored procedure. This will avoid frequent updation details about the affected rows to the server.
7. Avoid using views to retrieve the datas instead we can directly hit the tables.

8. Normalisation is the key concept to increase the performace of database.

9. Frequently updating the statistics will surely improve the performance.
10. Reindexing or reorganising the database will improve the performance of the databases.

Stored Procedure Vs User Defined functions in sql server

Stored Procedure:
Its a pre-compiled statements incorporating a set of T-SQL statements.
We can't use it in DML statements.
We can't use SP in Joins.
Stored procedure won't return table variables.
User defined functions:
Its a set of T-SQL statements. Repeated T-SQL statements can be grouped as a User defined functions.
We can use UDF's in DML statements and in joins.
UDF returns table variables.

"Like" Condition in sql server

"Like" condition is used to match the column datas with the necessary condition.
Consider my example i want to check for the names which starts with 'a' then the query resembles as below,
select name from venkatTable where name like 'a%'
Am trying to create a stored procedure to get the count with the column having the word "Ven"
Code Snippet
create procedure ImplementingLike
as
begin
select count(*) from VenkatTable where Name like '%Ven%'
end

Temporary Table Vs Table variable

Usage of Temporary table:
If we want to use the table for some other stored procedure or else to be used after my scope of the query. We will prefer temporary table.
Manually, before creating a temporay table we have to delete the existing one
Two types of tables can be created,
1. Local Temporary table
2. Global Temporary table
If we restart the server, temporary tables will get deleted.
Usage of table variable:
If we need table's existence to be restricted with in the scope of the query and no need to be used in future. then we can prefer table variable.
The table variables will automatically get deleted after the scope may be between a begin and end statements.

A new table variable cannot be created if an another table variable exists in the scope.

No need to explicitly drop the table.

Table variables are comparatively too fast in accessing the data because it will reduce the round trip like accessing the temp database to retrieve the data.

Constraints Vs Rules in sql server

Constraints:
Constraints are the condition provided on a column. If the column gets deleted by default, my constraint will get deleted.
Before applying the constraint the column should satisfy the condition.If i try to put a constraint on this column like the column should be unique, then my compiler will indicate an error like its not possible to create the constraint.

Rules:
Rules are nothing but the condition or terms created in the database and the column or table who want to implement that rule can use it.
If your trying to bind the rule with my column it wont think about your past data in the table and will try to abide for the future data

Cursor Vs While loop in sql server

Avoid using cursors in looping the table rows which will make a server roundtrip for each row. Instead, you can opt while loop (transfer the data to temp tables).

In cursors, we have to create the cursor, open it, use it, close it and deallocate the cursor. So we are facing additional overhead in case of using cursors.

Cursors are heavy weight object holds huge memory when compare to while loop.

In case of any breakage in the mid of looping the cursor we have to take care about the exception handling mechanism to de-allocate the cursor. Its an additional overhead for us.

Clustered index Vs Non Clustered index

Clustered index is used to sort the data physically. Where as non clustered index will have a reference to the data stored.

Clustered index is too fast where as non clustered index is comparatively slower.

Clustered index will hold huge memory for creation and for working when compared to non clustered index.

Only one clustered index can be created for a table where as 249 non clustered index can be created.

SQL server interview questions

Let see some basic T-SQL. On reading this article, you can straight forward attend an interview or you can take a SQL Server task.

CREATE TABLE EMPLOYEE(EmpID INT PRIMARY KEY , EmpFirstName VARCHAR(100),EmpLastName VARCHAR(100), City VARCHAR(10),ManagerID INT, Salary int ,Designation varchar(10))

CREATE TABLE EMPLOYEEDETAILS(EmpID INT , EmpQualification VARCHAR(100),EmpExtn INT)

1. Adding Constraint between two tables, to update a foreign key relation ship. You need to alter the child table.

ALTER TABLE EMPLOYEEDETAILS
ADD CONSTRAINT emp_for FOREIGN KEY (EmpID)
REFERENCES EMPLOYEE(EmpID)

2. Trying to insert into the child table.
INSERT INTO EMPLOYEEDETAILS VALUES(1,'BE',200)

You will get an error "The INSERT statement conflicted with the FOREIGN KEY constraint"
Its because, you need to populate data in the master table and corresponding column should be populated in the child table.

3. Trying to insert into the master table.

INSERT INTO EMPLOYEE(EmpID, EmpFirstName,EmpLastName,City,Salary,Designation) VALUES(1,'Venkat','Prabu','Dharmapuri',1000,'PM')

Output:
(1 row(s) affected)

INSERT INTO EMPLOYEE(EmpID, EmpFirstName,EmpLastName,City,Salary) VALUES(1,'Venkat','Prabu','Dharmapuri',1000)

On executing the above statement, we will get
Violation of PRIMARY KEY constraint 'PK__EMPLOYEE__3C69FB99'. Cannot insert duplicate key in object 'dbo.EMPLOYEE'.
Its because we are trying to insert duplicate key into the primary key column.
Let make a try with other insert statements,

INSERT INTO EMPLOYEE(EmpID, EmpFirstName,EmpLastName,City,Salary,ManagerID,Designation) VALUES(2,'Arun','Prabu','Dharmapuri',500,1,'Dev')
INSERT INTO EMPLOYEE(EmpID, EmpFirstName,EmpLastName,City,Salary,Designation) VALUES(3,'Karthi','Prabu','Salem',2000,'Lead')
INSERT INTO EMPLOYEE(EmpID, EmpFirstName,EmpLastName,City,Salary,ManagerID,Designation) VALUES(4,'Lakshmi','Prabu','Chennai',100,3,'Dev')

select * from Employee
Lets make a try to insert a row in the child table.
INSERT INTO EMPLOYEEDETAILS VALUES(1,'BE',200)
INSERT INTO EMPLOYEEDETAILS VALUES(2,'MBA',100)
INSERT INTO EMPLOYEEDETAILS VALUES(3,'BA',10)
INSERT INTO EMPLOYEEDETAILS VALUES(4,'BE',50)
INSERT INTO EMPLOYEEDETAILS VALUES(4,'BE',500)
--delete from Employeedetails where EmpID=1
select * from Employeedetails

4. Employee earning maxiumum salary

select max(salary) from EMPLOYEE

I need the max salary on each designation
select max(salary),designation from Employee Group by designation

I need max salary based on employee city
select max(salary),city from Employee Group by city

I need to check the max salary of the employees who is having salary >=1000 based on city.
select max(salary),city from Employee where Salary >=1000
Group by city

Total salary given to employees by the company
select sum(salary) from Employee

Total salary given to employees grouped by designation
select sum(salary),designation from Employee Group by designation

Total employees available in the company
select count(*) from employee

5. Employee Search

I need an employee with First name as "Venkat"
select EmpID,EmpFirstName from employee where EmpFirstName='Venkat'

I need an employee with Firstname start with "V"
select EmpID,EmpFirstName from employee where EmpFirstName like 'V%'



I need an employee with Firstname having second letter as "e"
select EmpID,EmpFirstName from employee where EmpFirstName like '_e%'

I need an employee with firstname ended with the letter "t"
select EmpID,EmpFirstName from employee where EmpFirstName like '%t'

I need an employee whose city is "Chennai"
select EmpID,EmpFirstName from employee where city ='Chennai'

6. List down the employees having more than one extension number
select empid from employeedetails group by empid having count( EmpExtn)>1
7. Fetch the employee based on EmpQualification
select a.EmpID,a.EmpFirstName,a.Salary,a.Designation, b.EmpQualification from Employee a
inner join EmployeeDetails b on a.EmpID=b.EmpID



To avoid duplicates we need to used the distinct keyword
select distinct a.EmpID,a.EmpFirstName,a.Salary,a.Designation, b.EmpQualification from Employee a
inner join EmployeeDetails b on a.EmpID=b.EmpID
INSERT INTO EMPLOYEE(EmpID, EmpFirstName,EmpLastName,City,Salary,Designation) VALUES(5,'Santhi','Jayakantham','Dharmapuri',1000,'PM')


To list down all the rows from the left table with matching columns in the right table. This can be achieved using Left outer join.
select distinct a.EmpID,a.EmpFirstName,a.Salary,a.Designation, b.EmpQualification from Employee a
left outer join EmployeeDetails b on a.EmpID=b.EmpID

Appropriate right tables column will be appended with Null value.
What about getting the all the right table row with corresponding matching column from the left table.

select distinct a.EmpID,a.EmpFirstName,a.Salary,a.Designation, b.EmpQualification from Employee a
right outer join EmployeeDetails b on a.EmpID=b.EmpID

Getting the matching data from two tables. Suppose I need to list the employees who is having qualification = 'BE'
select distinct a.EmpID,a.EmpFirstName,a.Salary,a.Designation, b.EmpQualification from Employee a
inner join EmployeeDetails b on a.EmpID=b.EmpID where b.EmpQualification='BE'

8. List down all the managers and their employee ID
select b.ManagerID,a.EmpFirstName as ManagerName from employee a
inner join employee b on a.EmpID=b.ManagerID

List down the employees who is having managers,
select b.EmpID,b.EmpFirstName,b.ManagerID,a.EmpFirstName from employee a
inner join employee b on a.EmpID=b.ManagerID

List down all the employees with managers details(If exists)
select b.EmpID,b.EmpFirstName,b.ManagerID,a.EmpFirstName from employee a
right outer join employee b on a.EmpID=b.ManagerID

TSQL Interview Questions - Part2

T-SQL Interview Questions: (SQL Server Interview questions)
Considering am having two tables,

Considering am having two tables,
create table Employees(empid int, empname varchar(10),desig varchar(10),salary int, mgrid int)
insert into employees values(1,'aa','pm',10000,1)
insert into employees values(2,'bb','pm',10000,1)
insert into employees values(3,'cc','pl',500,2)
SELECT * FROM employees
SELECT * FROM employees
create table employeedetails (empid int, City varchar(10), Telephone int)
insert into employeedetails values(1,'sydney',10)
insert into employeedetails values(1,'sydney1',10)
SELECT * FROM employeedetails

The table structure should resemble as below,

Employees (empid, empname, Designation, salary, mgrid )
EmployeeDetails (empid, City, Telephone)

5. Group the employees based on the designation. Need the number of employees in each designation
SELECT Designation,COUNT(Designation) FROM employees GROUP BY Designation

6. Retrieve the number of employees having more than one phone number
SELECT distinct * FROM employeedetails A
INNER JOIN
(select empid,telephone,count(*) as cnt from employeedetails group by empid,telephone)t
ON A.empid = t.empid
WHERE t.cnt>1
7. Select the details of 3 max salaried employees from employee table.SELECT TOP 3 empid, salary
FROM employee
ORDER BY salary DESC

8. Update 5 percent salary increment for all employees

UPDATE employees SET Salary = (Salary *105)/100
9. Display all managers from the table. (manager id is same as emp id)

select * from employees where empid IN (SELECT DISTINCT mgrid FROM employees)

10. Listing all the employees with Managers available
select a.empid,a.empname,b.mgrid,b.empname from employees a
inner join employees b
on a. mgrid =b.empid

SQL Server Interview questions

What is the significance of NULL value and why should we avoid permitting null values?Null means no entry has been made. It implies that the value is either unknown or undefined.
We should avoid permitting null values because
Column with NULL values can't have PRIMARY KEY constraints. Certain calculations can be inaccurate if NULL columns are involved.


What is SQL whats its uses and its component ?
The Structured Query Language (SQL) is foundation for all relational database systems. Most of the large-scale databases use the SQL to define all user and administrator interactions. It enable us to retrieve the data from based on our exact requirement. We will be given a flexibility to store the data in our own format.

The DML component of SQL comprises four basic statements:
* SELECT to get rows from tables
* UPDATE to update the rows of tables
* DELETE to remove rows from tables
* INSERT to add new rows to tables

What is DTS in SQL Server ?
Data Transformation Services is used to transfer the data from one source to our required destination. Considering am having some data in sql server and I need to transfer the data to Excel destination. Its highly possible with dialogue based tool called Data Transformation services. More customization can be achieved using SSIS. A specialized tool used to do such migration works.
What is the difference between SQL and Pl/Sql ?
Straight forward. SQL is a single statement to finish up our work.
Considering, I need some data from a particular table.
“Select * from table” will fetch the necessary information. Where as I need to do some row by row processing. In that case, we need to go for Programming Logic / SQL.
What is the significance of NULL value and why should we avoid permitting null values?
Null means no entry has been made. It implies that the value is either unknown or undefined.
We should avoid permitting null values because
Column with NULL values can't have PRIMARY KEY constraints. Certain calculations can be inaccurate if NULL columns are involved.
Difference between primary key and Unique key?
Both constraints will share a common property called uniqueness. The data in the column should be unique. The basic difference is,
· Primary key won’t allow null value. Whereas, unique key will accept null value but only one null value.
· On creating primary key, it will automatically format the data inturn creates clustered index on the table. Whereas, this characteristics is not associated with unique key.
· Only one primary key can be created for the table. Any number of Unique key can be created for the table.


What is normalization?
Normalization is the basic concept used in designing a database. Its nothing but, an advise given to the database to have minimal repetition of data, highly structured, highly secured, easy to retrieve. In high level definition, the Process of organizing data into tables is referred to as normalization.

What is a stored procedure:
Stored procedures are precompiled T-SQL statements combined to perform a single task of several tasks. Its basically like a Macro so when you invoke the Stored procedure, you actually run a set of statements. As, its precompiled statement, execution of Stored procedure is compatatively high when compared to an ordinary T-SQL statement.

What is the difference between UNION ALL Statement and UNION ?
The main difference between UNION ALL statement and UNION is UNION All statement is much faster than UNION,the reason behind this is that because UNION ALL statement does not look for duplicate rows, but on the other hand UNION statement does look for duplicate rows, whether or not they exist.

Example for Stored Procedure?
They are three kinds of stored procedures,
1.System stored procedure – Start with sp_
2. User defined stored procedure – SP created by the user.
3. Extended stored procedure – SP used to invoke a process in the external systems.
Example for system stored procedure
sp_helpdb - Database and its properties
sp_who2 – Gives details about the current user connected to your system.
sp_renamedb – Enable you to rename your database


What is a trigger?
Triggers are precompiled statements similar to Stored Procedure. It will automatically invoke for a particular operation. Triggers are basically used to implement business rules.

What is a view?
If we have several tables in a db and we want to view only specific columns from specific tables we can go for views. It would also suffice the needs of security some times allowing specfic users to see only specific columns based on the permission that we can configure on the view. Views also reduce the effort that is required for writing queries to access specific columns every time.
What is an Index?
When queries are run against a db, an index on that db basically helps in the way the data is sorted to process the query for faster and data retrievals are much faster when we have an index.

What are the types of indexes available with SQL Server?
There are basically two types of indexes that we use with the SQL ServerClustered - 1. It will format the entire table, inturn physically sort the table.
2. Only one clustered index can be created for a table.
3. Data will be located in the leaf level.
4. By default, primary key will create clustered index on the table.
Non-Clustered Index – 1. It wont touch the structure of the table.
2. It forms an index table as reference to the exact data.
3. A reference to the data will be located in the leaf level.
4. For a table, we can create 249 non clustered index.