.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!



Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

what is the use of except keyword in sql server?

Posted By: Deco     Posted Date: September 20, 2010    Points:2   Category :Sql Server
Please give me the exact use of except key word in sql server
with an example

Responses
Author: Syed Shakeer Hussain          Accepted Answer   
Posted Date: September 20, 2010     Points: 10   

Hi,
Except :-

To return all rows in table1 that do not match exactly the rows in table2, we can just use EXCEPT like this:



select * from table1 except select * from table2




Author: Suthish Nair             
Posted Date: September 20, 2010     Points: 5   


Microsoft introduced the EXCEPT operator in SQL Server 2005, which returns all of the distinct rows from the left side of the EXCEPT operator. It also removes all of the rows from the result set that match the rows that are on the right side of the EXCEPT operator.


refer example:

http://blog.sqlauthority.com/2008/08/07/sql-server-except-clause-in-sql-server-is-similar-to-minus-clause-in-oracle/
http://www.databasejournal.com/features/mssql/article.php/3602601/Except-Operator-in-SQL-Server-2005.htm

suthish nair
Author: Asha.MP          Accepted Answer   
Posted Date: September 21, 2010     Points: 10   

hi...

Except is like minus,

considar two tables
Table1
name id address
----------------------
asha 1 Tumkur
usha 2 Tumkur
ashok 3 Bangalore

Table2
name id address
---------------------
asha 1 Tumkur


select * from Table1
Except
select * from Table2

this query result in two rows as

name id address
------------------------
usha 2 Tumkur
ashok 3 Bangalore

Thanks and Regards,
Asha.mp


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend