Use this space to put some text. Update this text in HTML

468x60 banner ad

Advertise with Us

Powered by Blogger.

Wednesday 2 March 2016

SQL Alias

sql Alias is used to give an alias name to a column or a table. This is used for giving short name of a column and a table. you have to use alias, when column name is large or you can combine two column in a single column name or more readable.


SELECT * FROM Employee


 Aliases for columns:

SELECT
column-name as alias-name
from
table-name

Example1:

SELECT
  First_name AS [Employee Name]
FROM Employee

Result:


In the above query, the column First_name is given a alias as "Employee Name". So when the result is displayed the column name appears as "Employee Name" instead of  'First_name'.

Example2:


SELECT
  First_name + ' '+ Last_name AS [Employee Name]
FROM Employee


Result:




In the above query, the column First_name and Last_name combine together to display a single column as alias as "Employee Name". So when the result is displayed the column name appears as "Employee Name" instead of  "First_name" and "Last_Name". 

Table Name Alias

Syntax:
 
SELECT column-name
from table-name as alias-name


Example1:

Consider Two tables, First is Employee and Second is tblDepartment. 

SELECT
  emp.First_name, emp.Last_name,emp.Salary, emp.Joining_date, Department_ID
FROM Employee emp
 


SELECT dept.Id, dept.Name as [Department Name]
FROM tblDepartment dept





Below is the Query to fetch data from both the tables using SQL Alias,
 

SELECT 
  emp.First_name, emp.Last_name,emp.Salary, emp.Joining_date,
  dept.Name as [Department Name] 
from Employee as emp
INNER JOIN tblDepartment as dept
ON emp.Department_ID=dept.Id
 
Result

 

 

 


 



















 

 

 
  
  

Tuesday 1 March 2016

outlook doesn-t update emails unless you click send receive


The default setting for send/receive is 30 minutes. If someone send me mail and we are not received mail immediately means we have to make change in send/received settings 30 minutes to 2 minutes.

I am referring to the settings in Tools -> Options -> Mail Setup -> then look in the Send/Receive section.



Polymorphism in C-Sharp


1. In Polymorphism poly means “multiple” and morph means “forms” that means many forms.
2. In polymorphism we will declare methods with same name and different parameters in same class.
3. or methods with same name and same parameters in different classes.
In Polymorphism we have 2 different types those are
     -      Compile Time Polymorphism (Called as Early Binding or Overloading or static binding)
     -      Run Time Polymorphism (Called as Late Binding or Overriding or dynamic binding)

Compile Time Polymorphism or Early Binding

Compile time polymorphism means we will declare methods with same name but different signatures because of this we will perform different tasks with same method name. This compile time polymorphism also called as early binding or method overloading.
Method Overloading or compile time polymorphism means same method names with different signatures (different parameters)
Example


public class Class1
{
public void NumbersAdd(int a, int b)
{
Console.WriteLine(a + b);
}
public void NumbersAdd(int a, int b, int c)
{
Console.WriteLine(a + b + c);
}
}
In above class we have two methods with same name but having different input parameters this is called method overloading or compile time polymorphism or early binding. 

Run Time Polymorphism or Late Binding

Run time polymorphism also called as late binding or method overriding or dynamic polymorphism.
Run time polymorphism or method overriding means same method names with same signatures.
In this run time polymorphism or method overriding we can override a method in base class by creating similar function in derived class this can be achieved by using inheritance principle and using “virtual & override” keywords.
Example




public class clsShape
    {
        public int _radius = 5;
        public virtual double getArea()
        {
            return 0;
        }
    }
    public class clsCircle : clsShape
    {
        public override double getArea()
        {
            return 3.14 * _radius * _radius;
        }
    }
    public class clsSphere : clsShape
    {
        public override double getArea()
        {
            return 4 * 3.14 * _radius * _radius;
        }
    }




As you can see from above code that we have one base class "clsShape" with a "virtual" method "getArea()" and two derived classes "clsCircle" and "clsShape" each having an "override" method "getArea()" with different implementations.