Monday, July 6, 2009

Union and UnionAll

Union:its Like a join Command.When using the union all the selected columns need to be of the same datatype.Only distinct values are selected.

Union All :it almost like union.There is no distinct operation so it will take all the values.

Rules for Union
a union must be composed of two or more select statement and each is separated by a keyword union
Each union must contain same column,expression or aggregate function.
Column name need not be same ,but they must be the type that the sql can implicitly convert.