Pages

Saturday 2 July 2011

Set Operators in SQL Server.

2 comments
 
Hi Friends,in this post i would like to explain Set Operators in SQL Server.

*Set Operators are used to combined the data from multiple tables.

Set Operators:
1)UNION
2)UNION ALL
3)INTERSECT
4)EXCEPT

Syntax:
Select query1

Select query2

Select query3

......
......
......

1)UNION
*UNION can select only distinct/unique rows & rows can be arranged in ascending order.

2)UNION ALL
*UNION ALL is used to combine all rows from the given select queries.

3)INTERSECT
* UNION ALL is used to select only common rows from the given set of select queries.

4)EXCEPT
* EXCEPT is equalent to Minus operator in Oracle.To select all rows from the first query,except second query output.

Limitations:
* All queries should have equal number of columns.
* Corresponding column data types should be same.

Thank you...

Shout it

2 Responses so far.

  1. Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write ups thanks once again.

  2. Memtech says:

    Check out this link too...

    http://mindstick.com/Articles/06d3a8e1-041c-4b81-8e0a-1de64fb9e2b9/?SQL%20Operator%E2%80%99s

    Its also having a wonderful explanation on sql operators in sql server.

    Thanks

Leave a Reply