JayceOoi.com

- Technology, mobile, photography, gaming, programming, anything -

Hmm… I have been using SQL for quite some time. But I do not know how to compare 2 tables to find out the different records. For example, I have 2 tables which are table A and table B. Both of them have some similar records. But I want to filter out the different data only. How can I do so? I searched online and discovered the method to do so. It is located in Microsoft SQL Server 2005 Books Online. All we need to do is use EXCEPT function in SQL.

Query to compare 2 tables to find the different

SELECT * FROM TableA EXCEPT SELECT * FROM TableB;

Query to compare 2 tables to find the matches

SELECT * FROM TableA INTERSECT SELECT * FROM TableB;

Hope this will help you too. ;)

How to delete / drop SQL table?

How to delete / drop SQL table? The following code will guide you to drop the temporary SQL table. Basically, you just need to type in ‘DROP TABLE tableName‘.

IF OBJECT_ID(N’tempdb..#temptable’, N’U') IS NOT NULL
DROP TABLE #temptable;
GO

How to create temporary SQL table

How to create temporary SQL table? Just look at below CREATE TABLE statement.

CREATE TABLE #tempTable (
ID int,
Name char(30) )

(more…)




Featured ...

Patriot FUEL+ 6000 & 9000 mAh Mobile Rechargeable Battery Review
64GB SanDisk Extreme microSDXC UHS-I Card Review
64GB Samsung microSDXC Pro UHS-1 Card Review

Guide for ...

Samsung Galaxy Note 3
Google Nexus 7 (2013)
Samsung Galaxy S4
Google Nexus 4
Samsung Galaxy Note 2
Google Nexus 7
Samsung Galaxy S3
HTC One X
Amazon Kindle Fire
Samsung Galaxy S2
HTC HD2

Follow ...